Monday Sep 24, 2012

Deploying Oracle ADF Essentials Applications to Glassfish

With the new Oracle ADF Essentials offering you can now deploy applications that leverage Oracle ADF on the open source Glassfish 3.1 server.

Deployment is documented in the official JDeveloper and ADF documentation (here) but below is a summary of the steps and a video of the steps you'll need to take to get a basic Oracle ADF Essentials application to work on GlassFish.

Note - to make starting/stopping GlassFish easier for my demo I used my GlassFish extension that you can get here.

First we'll install some ADF Runtime libraries on GlassFish

  1. Download and install Glassfish (Note - if you also have an Oracle DB on the same machine, you'll want to switch GlassFish's HTTP port to something else instead of 8080).
  2. Download the Oracle ADF Essentials packaging - this will get you an file.
  3. Copy the to the lib directory of your Glassfish domain - on a default windows install this would be: C:\glassfish3\glassfish\domains\domain1\lib
  4. Go the the above lib directory and issue a unzip -j

This will extract the ADF libraries to the directory. Now you can start the Glassfish server.

Now let's configure Glassfish to handle applications of the ADF type:

  1. Invoke the admin console of glassfish (http://localhost:4848) and log into your admin account.
  2. Go to Configurations->Server-config->JVM Settings and choose the JVM Options tab
  3. Add the following entries:
    • -XX:MaxPermSize=512m (note this entry should already exist so just make sure it has a big enough value)
    • -Doracle.mds.cache=simple

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

  1. Go into Resources->JDBC->JDBC Connection Pools and click to create a New one
  2. Give it a name and choose the resource type to be javax.sql.XADataSource and choose Oracle as the Database Driver vendor. Click Next
  3. 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, databaseName = XE, Password=hr, ServerName=localhost, DriverType=thin, PortNumber=1521)
  4. Click Finish
  5. Click Ping to check your connection works.
  6. Now define a new JDBC Resource that will use the pool you just defined. In my example I called the resource jdbc/HRDS

You will need this name to match the name in your Application Module connection configuraiton.

Now you can re-start the Glassfish server for the changes to take effect.
  1. Get an ADF application going (you can use the regular Fusion Application template for this)
  2. Go into the project properties of your viewController project, under the deployment section click to edit the deployment profile that is defined there.
  3. Go to Platform and choose Glassfish 3.1 from the drop down list. Click ok to go back to your project.
  4. Go to Application -> Application Properties-> Deployment
  5. Go to Platform and choose Glassfish 3.1 from the drop down list. Click ok to go back to your project.
  6. This step will make sure that JDeveloper will autoamtically add the necessary ADF libraries to the EAR file that is being generated for deployment on Glassfish
  7.  Go to your Application->Deploy and deploy either to an EAR file or directly to a Glassfish server connection that you created.

Things should just work, but if they don't then look up the server.log in the log directory and check out what error is in there.

Here is a video demo of the various steps:

Note - right now the deployment of an ADF application takes about 2 minutes on my machine we are hoping to be able to improve this timing in the future. People who are more familiar with Glassfish might want to explore using exploded directory deployment and see if they can get it to work.

 FAQ - some common questions/problems that people posted on comments:

  • "The zip in the video is 70mb, OTN's zip is 20mb" - that's fine. The video was recorded with a pre-production version of the zip. The 20mb zip of adf-essentials is all you need.
  • "My JDeveloper log window show an error on deployment - "status of 400 Deployment cancelled." " - To better understand where the problem is check your server.log file in under your GlassFish server. This will give you the actual error message. 
  • "I'm getting a class not found error in the server.log when trying to deploy" - this usually means one of two things:
    • 1 - you didn't use a -j when unzipping the file - so you ended up with sub directories in your lib directory. -j will get all the jar files to be extracted into a single directory.
    • 2 - you didn't specify Glassfish as the platform in the deployment profile for both the viewController project and your application level. Without doing this JDeveloper won't know to include all the needed jars in the EAR file it is producing. Check the EAR file you got from JDeveloper - if it is smaller than 30MB - you probably skipped this step. 


GlassFish Extension for Oracle JDeveloper

We just release a new version of Oracle JDeveloper -

One new feature here is built-in support for GlassFish. This include the ability to create an "application server" connection to GlassFish and then deploy to that server with one click from inside JDeveloper. You can use this for deploying Oracle ADF Essentials application on Glassfish, but you can also use it to deploy any Java EE application you build in JDeveloper on GlassFish.

However, if you are planning to work with GlassFish and JDeveloper on a more regular basis as your development server, then you might find my new extension useful.

The new extension allows you to start and stop an external GlassFish instance, as well as start it in debug mode (which will allow JDeveloper to remotely debug your application as it runs on the server. I also added a button that will invoke the web admin console of Glassfish.

Here is a quick demo that will show you how to work with the extension:

The extension is available from help->check for updates, or you can download it directly from here, and then use help->check for updates pointing to the local zip file.

[update Nov-2012] - The new version 1.3 now runs on Mac and Linux thanks to updates to the source code by Alexis Lopez and David Aroca. Make sure to download that latest version, I also added the option to disable the extension from tools->features in JDeveloper.

By the way if you want to improve or modify this extension you can find the source for it here. You can also use this as a way to learn a bit about building JDeveloper extensions.


I'm a Director of Product Management for Oracle's Cloud Development Tools and Frameworks.
Follow me:

« September 2012 »