Friday, September 28, 2012

ADF Essentials in the RedHat Cloud (Glassfish / OpenShift)


RedHat OpenShift Cloud


In this post we (Ulrich @GerkmannBartels (,@multikoop, are going to show how to setup the runtime environment for running ADF Essentials Applications on Glassfish in RedHats OpenShift Cloud. For the moment we are not going to connect to any database. What we are actually going to show is
  • Setup Glassfish on OpenShift Cloud
  • Configure appropriate JVM settings
  • Install ADF Share Libraries into Glassfish Domain
  • Deploy ADF Essentials Application (currently with no database access)


Step 1: Sign up for free OpenShift account (if needed)
Goto and register for a free account if you do not have one yet.
All you need is a valid emailadress. You will get 1.5G Memory and 3G Storage

Step 2: Create new Cloud Application
Login through the web interface and create a new application, i.e. adf with the Do-It-Yourself Catridge. This is pretty easy. Just log into your Openshift account and choose create application. Choose the following catridge

After that, just follow the instructions and you are done. This is really easy. Believe me!

Step 3: Prepare your client for the cloud
Well, this actually depends on your OS. You can read a detailed instruction about it here:

On a Mac: Open Terminal and enter:

enpitmac:~ak$ sudo gem install rhc
Successfully installed jruby-pageant-1.1.1

This will install the RedHat Client tools. Test the availability of rhc via

enpitmac:~ ak$ rhc -version
rhc 0.98.16
enpitmac:~ ak$ 

Setup OpenShift environment on your client

enpitmac:~ ak$ rhc setup

Starting Interactive Setup for OpenShift's command line interface
To connect to enter your OpenShift login (email or Red
Hat login id): <your id>
Password: *******

Next step: I would like to access the cloud by ssh. So to get this, we need to setup up an SSH equivalence, which actually the red hat client tools are doing for us. For me it was done, when I just send the first command with rhc, i.e.

enpitmac: ak$ rhc app
Password: *******

Starting Interactive Setup for OpenShift's command line interface

It looks like you have not configured or used OpenShift client tools on this computer. We'll help you configure the client tools with a few quick questions.

The OpenShift client tools have been configured on your computer.  You can run this setup wizard at any time by using the command 'rhc setup' We will now execute your original command (rhc app)
enpitmac:~ ak$ 

Well, the command 'rhc app' does not exists, but it helped to setup the ssh equivalence.

Step 4: Install Glassfish
OK, now the fun part starts. After we have setup OpenShift, lets get glassfish running . The easiest way is to log into your open shift cloud through ssh and download the glassfish right into your repository directory.

Goto choose your application and then expand 'WANT TO LOG I TO YOUR APPLICATION' Item. Here you will see the ssh command which allows you to login from your local machine.

Once logged in grab the latest GlassFish binaries into your repository directory:

Since it is not allowed to start more than one http-listener on port 8080 on openshift cloud, we have to adjust the glassfish domain.xml configuration. (Read more about this here: )

In order to make life easier you can download the preconfigured domain.xml from our server.

In short: it contains the following (main) changes which are needed in order to be able to run Glassfish for ADF Essentials on Openshift.

b) deactivate http-listener2 (Openshift only allows to run one listener, no admin console will be available)


c) ADJUST MaxPermSize to:
d) Configure simple MDS Cache:

C.4.3 How to Configure the JVM Cache 
for detailed instructions of the Oracle ADF Admin Guide.)

Start / Stop Glassfish by start / stop hooks of your OpenShift application

Adjust start script hook
# The logic to start up your application should be put in this
# script. The application will work only if it binds to
cd $OPENSHIFT_REPO_DIR/diy/glassfish3/glassfish/domains/domain1/config/
mv domain.xml domain.xml_2
sed 's/'$( grep serverName domain.xml_2 | cut -d\" -f 2 )'/'$OPENSHIFT_INTERNAL_IP'/g' domain.xml_2 > domain.xml
../../../bin/asadmin start-domain &> $OPENSHIFT_LOG_DIR/server.log

Adjust stop script  hook
kill `ps -ef | grep glassfish3 | grep -v grep | awk '{ print $2 }'` > /dev/null 2>&1
exit 0

TEST if your Glassfish is running by typing from your client terminal

enpitmac:~ ak$ rhc app start -a adf

Check on Browser


Well, the basis is done. Now we need to get the ADF Share Libraries onto Glassfish
C.3 Configuring GlassFish with ADF Runtime Libraries 
for detailed instructions of the Oracle ADF Admin Guide.)

Copy onto the $GF_DOMAIN_HOME/lib with scp und unzip (with -j , this is important) 
enpitmac:~ ak$ scp Downloads/                                                                          100%   21MB  25.6KB/s   13:48   
enpitmac:~ ak$ ssh
[ ~]\> cd adf/repo/diy/glassfish3/glassfish/domains/domain1/lib
[ lib]\> unzip -j
Label: JDEVADF_11.
  inflating: adf-controller-security.jar 
  inflating: adf-share-security.jar 
[ lib]\>

Now restart glassfish to grab the changes! ~]\> ./adf/repo/.openshift/action_hooks/stop
.. ~]\> ./adf/repo/.openshift/action_hooks/start

Create a simple ADF Application and copy it into the autodeploy folder
enpitmac:~ ak$ cd Workspace/enpit-base/development/enpit.sample/

enpitmac:deploy ak$ scp enpit-sample-app1.ear <.....><...>/adf/repo/diy/glassfish3/glassfish/domains/domain1/autodeploy
enpit-sample-app1.ear                                                                       100%   64MB  18.1KB/s   59:55   
enpitmac:deploy ak$ 

(BTW: I must say the size of the EAR for ONE single ADF UI View just sucks: more than 60MB.  IMHO not ready for the cloud!)

Anyway, after doing all that above the running application should be satisfying ;)


  • Hopefully Oracle will unveil the Oracle Cloud for everyone who wants to run / try out ADF ;). Please !



  1. Hi,how did you deploy an EAR on Glassfish?
    The only Type one comes across is Web Application.
    When i tried to select EAR package, i get this:
    Error occurred during deployment: no container associated with application of type : ear. Please see server.log for more details.

  2. my problem is when i try to deploy war, i get error:
    Error occurred during deployment: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.IllegalArgumentException: java.lang.ClassNotFoundException: oracle.adf.share.glassfish.listener.ADFGlassFishAppLifeCycleListener

    could you come up with an idea?

  3. Hello Bond Buster,

    a) having the GF Administration console / server you have many options too deploy the EAR. Right from the web interface or through the asadmin cli tool.

    For the deployment on Openshift I used the autodeploy feature which means just copying the EAR to the $DOMAIN/autodeploy directory.

    b) The EAR of course should be created by the correct deployment profile from within jdeveloper or ojdeploy. Otherwise the deployment will not work.

    c) Do not try to deploy the WAR. It will not work since Oracle writes the following in the dev guide "For Oracle ADF applications, WAR files can be deployed only as part of an EAR file" ;) See for more information on "ADF on GlassFish".

    Best regards,

    1. Hello Bond Buster,

      Were you using a web profile at that time?
      You need to use the full glassfish profile to deploy an ear file.

      Kind Regards,
      Herman Mensinga

  4. Hi i folllow this tutorial and i have my glassfish running. Then i add the MySql cartridge and create a my question is how i create a datasource in my glassfish that points to the mysql cartridge. Since we dont have the console i try to modify the domain.xml config file but i have no success. Any ideas??? Sorry for my english.

    1. Hi Sebastian,

      Did you ever find a solution to this?

      Kind rgds

    2. No, since i cant did that i try another solutions like Amazon EC2 or DigitalOcean or Jelastic :) . Did you find a solution?

  5. Hello Sebastian,

    I am sorry but in that case I did not go further so I have to research myself. I hope there is some help in the Glassfish Community.


  6. Hi Koop,

    It may be a silly question to ask, but I really didn't get following point as you said :
    Once logged in grab the latest GlassFish binaries into your repository directory:
    [ diy]\> wget

    I am on windows 7 and my command prompt says "wget" is invalid command, I have installed git and RHC Client tools and they are working fine.
    So please help me to configure GF Server.


    1. Hi, I have not tested it from Windows Machines. The "wget command" is meant to be executed on the openshift cloud machine.

      If you are on Windows your best choice is to use Putty to log on to your openshift machine. Then everything should work as expected.


  7. I used the domain.xml from here: wget I'm assuming I don't have to do the other steps you've outlined. But when I try to start GF it says there are no domains. What am I doing wrong? Thanks!