Running your ADF Essentials application on Glassfish 3

For some of our own internal applications, we (AMIS) are using 2 products of Oracle that do not require any license to be payed: ADF Essentials and the Oracle XE database.

These applications were initially deployed to a Tomcat 6 server, only when trying to deploy new applications we encountered issues with conflicting libraries. As the Glassfish Open Source edition is also free and well documented and supported I decided to investigate a switch.

Since ADF Essentials is available more than a year, posts about using ADF Essentials with Glassfish are there already. Take this one for example by Shay Smeltzer. But in these posts there was always something missing, in this post I share the steps I needed for a working deployment to a remote server (in the cloud in my case).

Environment

First my assumptions/environment:

  • Combination Oracle XE 11g, ADF essentials 11g r2 and Glassfish Open Source Edition 3.1
  • The ADF application uses a JDBC datasource
  • Glassfish will be running on a server on which the (Oracle XE) database is also running
  • The Glassfish Admin console is accessed remotely

Installing and configuring Glassfish

First we check that a JDK 6 or 7 is installed on the server. If not please install JDK 7.

Next we download glassfish.
You need to download the 3.1 Full Platform version!
There is also a complete zipped installation you only need to unzip.

Install Glassfish, a link to the documentation can be found on the download page.

Start the glassfish server. When you use the zip-file you can start the domain using:
<unzip-directory>\glassfish3\bin>asadmin start-domain

You should now be able to start the admin-console in a browser using http://<hostname>:4848/

gf1

If you have a database running on the same server you can better change the default http-port. Update the default http-port from 8080 to say 8484:

  • Expand folder: Configuration | server-config | HTTP Service | HTTP Listeners | http-listener-2
  • Update the port and save

gf2

For ADF essentials we need to update two settings:

  • Configurations | Server-config | JVM Settings
  • choose the JVM Options tab
  • Update the following entry:
    -XX:MaxPermSize=512m
    (note if the value is larger than 512m you can leave it to that)
  • Add the following entry:
    -Doracle.mds.cache=simple

gf3

While we are in the admin console, we can also define JDBC connections that will be used by our application.

  • Go into Resources->JDBC->JDBC Connection Pools
  • Create a New one and give it a name
  • Choose the resource type to be javax.sql.XADataSource
  • Choose Oracle as the Database Driver vendor.
  • Click Next
  • Scroll down to the Additional Properties section and start filling in the information for your database.
    The values for an Oracle XE will be
    (user=hr, Password=hr, url=jdbc:oracle:thin:@hostname:1521:XE)
  • Click Finish
  • Click Ping to check your connection works.
  • Define a new JDBC Resource that will use the pool you just defined, you will need this name to match the name in your Application Module connection configuration.

Downloading ADF Essentials library

Adf Essentials library download

Unzip the library in <unzip-directory>/glassfish3/domains/<domain>/lib directory using “unzip -j” (you do not want the directories, only the jar-files).

Restart the glassfish server:

  • <unzip-directory>\glassfish3\bin>asadmin stop-domain
  • <unzip-directory>\glassfish3\bin>asadmin start-domain

 

Preparing your application for deployment

  • Go into the project properties of your viewController project, under the deployment section click to edit the deployment profile that is defined there.
  • Go to Application | Application Properties | Deployment
  • Go to Platform and choose Glassfish 3.1 from the drop down list. Click ok to go back to your project.

gf4

This step will make sure that JDeveloper will automatically add the necessary ADF libraries to the EAR file that is being generated for deployment on Glassfish.

  • Go to your Application | Deploy
  • Deploy either to an EAR file or directly to a Glassfish server connection that you created.
  • An ear-file can be deployed manually in the admin-console by selecting Applications and uploading the ear-file

gf5

When running glassfish locally you can also deploy the ear to the domains autodeploy directory

Remote administration

Out-of-the-box, GlassFish Server 3.1 does not permit remote administration. This is to reduce your exposure to an attack from elsewhere in the network.  If you try to do remote administration GlassFish sends a “403 – Forbidden” HTTP status as the response.

You can turn remote administration on using

asadmin enable-secure-admin

which actually accomplishes two things.  It enables remote administration and also encrypts all admin traffic

Leave a Reply

  1. Please provide examples for Glassfish 4 as well.

    My application created with JDeveloper 12.1.3 deploys fine on GlassFish 3.1!

    But when I run it with Glass 4, configured as required I cannot deploy the EAR file

    I get this error when I try to deploy:

    [2014-09-03T09:19:05.086+0300] [glassfish 4.0] [SEVERE] [] [javax.enterprise.resource.webcontainer.jsf.config] [tid: _ThreadID=34 _ThreadName=admin-listener(3)] [timeMillis: 1409725145086] [levelValue: 1000] [[
    Critical error during deployment:
    com.sun.faces.config.ConfigurationException: java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: org/jvnet/hk2/component/Habitat