Although deployment of Oracle ADF 11g web applications on Tomcat is not officially supported, we have successfully deployed several ADF 11g applications on Tomcat 6. In fact, once you know which adjustments need to be made, it is easy to deploy an ADF application on Tomcat. This post will show you how it can be done and includes a small app which lets you browse departments in Oracle’s sample HR-schema.
First, prepare a Tomcat 6 environment for running ADF applications. This post explains how this can be done. The main steps are:
- Add all necessary libraries (.jar files) to Tomcat’s lib directory
- Add the Oracle data sources needed by your ADF application
Adjust ADF application for deployment on Tomcat
On Tomcat, we can only deploy a Web archive, so we need to make a .war file. This can be done with a deployment profile on the ViewController part of your project. In this profile we will exclude all library dependencies. Apart from that, we need to remove some lines in the web.xml file of our application: all web application listeners need to be removed, and the lines related to JpsFilter need to be removed.
Below I will explain these steps in detail, using a sample application named ADFOnTomcatDemo, which is available for download.
First of all, we need to get the right data source name. When we make a connection in JDeveloper, named
hrDS, the default data source name for our application module will be:
java:comp/env/jdbc/hrDS. The resource name in the server.xml of Tomcat will then be:
jdbc/hrDS. Check that the application is configured to use the JDBC DataSource:
After that, we are going to make a new deployment profile: right click the ViewController part of the project and choose “Project Properties”. Select “Deployment” on the left and click the “New…” button to make a new deployment profile. Choose Profile Type “WAR File” and give it a name, for instance “ADFOnTomcatDemo”. This will also be the default name for our WAR-file, but we can change that later on.
After clicking OK, we get into the screen for editing profile properties. In the category “General” we can change the WAR filename. This filename is important, because it will be the root-context for our Tomcat deployment and thus appear in the URL for our application. Check that we have the right name for our WAR file, and also check the file location, because we will copy the war file from here to the Tomcat webapp directory.
In this same window, click on ‘Library Dependencies’ and deselect all libraries which will appear on the right side:
Then click OK. The deployment profile is ready now.
Next, we will have to make some adjustments in the web.xml file of our project. Double click this file in the WEB-INF folder and expand the Web Application Listeners part. Delete all three entries that appear here.
Then, select “Filters” on the left side and delete the JpsFilter entry:
That’s all. Save the adjustments and make a war-file, using the deployment profile we just made. For this, right click the “ViewController” part of our project and choose “Deploy” to WAR-file. A WAR-file with the name ADFOnTomcatDemo.war will be made and you will find it in the deploy-directory within the ViewController-directory if you have accepted the default location.
Now we need the stop the Tomcat server, if it’s running, delete the previous entry in the webapps/ folder and put our WAR-file in there.
Start Tomcat and check for the following line in the logging:
If there are no error messages, then our deployment succeeded and we can access our page “BrowseDepartments.jsf” at the following URL:
provided that Tomcat is running locally and configured at the default port 8080.
This is the result for our sample demo application:
The sample application can be downloaded at: ADFOnTomcatDemo.