You can use the IBM Application Pattern for Java to create a virtual application or any Java-based middleware by providing the middleware as part of the application. A good example is deploying Apache Tomcat and a web application. You can do this in one of two ways: bundle both into an archive file you upload into the Java application component; or, deploy Apache Tomcat as the Java application, and deploy the web application using an Additional archive component. The second method is usually preferable, because it doesn't require the manipulation of archive files, and you can save the Apache Tomcat configuration as a template, just adding the web application to create a new virtual application.
Below are the steps to create a deployment of Apache Tomcat 7.0.27 with a sample web application added separately in the Virtual Application Builder. Start by downloading and saving both a Tomcat archive from Apache.org and then follow these steps:
- Drag a Java application widget from the palette to the canvas to be the Tomcat server. Optionally, give it a name (such as Apache Tomcat Server).
- In the Archive File configuration field, browse to the Tomcat archive that you've downloaded from Apache.org (apache-tomcat-7.0.27.tar.gz, for example). Use this file exactly as-is; you don't need to make any changes to it.
- Select Command Line as the Application launch type for the Java application component and specify the Tomcat launch script — for example, /apache-tomcat-7.0.27/bin/startup.sh. This is the launch script — provided in the download from apache.org — that is used to start the Tomcat server.
- Add a Connect In by dragging it from the Other Components under the palette's Assets onto the canvas, and configure it to allow connections on port 8080. This will open in the firewall for incoming connections on port 8080 that Tomcat will listen to.
- Drag a Monitored file from the Other Components list to the canvas and configure it to monitor the Tomcat log files — for example, /apache-tomcat-7.0.27/logs/*.log. This adds the log files created by Tomcat into the Log Viewer. The use of the *.log wildcard means that it will pick up all the .log files in that directory: catalina.log, manager.log, and so on.
- Add an Additional archive file for deploying a web application. Give it a Deploy path value of /apache-tomcat-7.0.27/webapps/ and chose Java archive file as the Type of archive file.
If you wanted to create an application or template for a different version of Tomcat, then the references to 7.0.27 will need to be changed to the relevant version - one of the side effects of the version being included in the directory names in the download packages from Apache.org.