VERSIONS / PLATFORM
ADF 11.1.2.3
GlassFish 3.1.2.2
RedHat OpenShift Cloud
INTRODUCTION
In this post we (Ulrich @GerkmannBartels (http://maybe-interesting.blogspot.com),@multikoop, www.enpit.de) 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)
SETUP GLASSFISH ON OPENSHIFT CLOUD
Step 1: Sign up for free OpenShift account (if needed)
Goto https://openshift.redhat.com 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
Step 3: Prepare your client for the cloud
Well, this actually depends on your OS. You can read a detailed instruction about it here: https://openshift.redhat.com/community/get-started
On a Mac: Open Terminal and enter:
enpitmac:~ak$ sudo gem install rhc
Password:
Successfully installed jruby-pageant-1.1.1
.......
enpitmac:~ak$
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 openshift.redhat.com enter your OpenShift login (email or Red
Hat login id): <your id>
Password: *******
enpitmac:~ak$
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 https://openshift.redhat.com/app/console/applications 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:
[adf-multikoop.rhcloud.com diy]\> wget http://download.java.net/glassfish/3.1.2.2/release/glassfish-3.1.2.2.zip
unzip glassfish-3.1.2.2.zip
...
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: https://openshift.redhat.com/community/blogs/running-java-apps-in-the-cloud-with-glassfish-and-a-paas )
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.
a) REPLACE ALL: localhost with OPENSHIFT_INTERNAL_IP
b) deactivate http-listener2 (Openshift only allows to run one listener, no admin console will be available)
CONFIGURE APPROPRIATE JVM SETTINGS FOR ADF ESSENTIALS
c) ADJUST MaxPermSize to:
<jvm-options>-XX:MaxPermSize=512m</ jvm-options>
<jvm-options>
d) Configure simple MDS Cache:
<jvm-options>-Doracle.mds.cache=simple
<jvm-options>-Doracle.mds.cache=simple
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
adf/.openshift/action_hooks/stop
#!/bin/bash
# The logic to start up your application should be put in this
# script. The application will work only if it binds to
# $OPENSHIFT_INTERNAL_IP:8080
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
adf/.openshift/action_hooks/stop
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
...
Result:
SUCCESS
Check on Browser
INSTALL ADF SHARE LIBRARIES FOR GLASSFISH
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 adf-essentials.zip onto the $GF_DOMAIN_HOME/lib with scp und unzip (with -j , this is important)
enpitmac:~ ak$ scp Downloads/adf-essentials.zip @adf-multikoop.rhcloud.com:/var/lib/stickshift//adf/repo/diy/glassfish3/glassfish/domains/domain1/lib
adf-essentials.zip 100% 21MB 25.6KB/s 13:48
enpitmac:~ ak$ ssh @adf-multikoop.rhcloud.com
...
[adf-multikoop.rhcloud.com ~]\> cd adf/repo/diy/glassfish3/glassfish/domains/domain1/lib
[adf-multikoop.rhcloud.com lib]\> unzip -j adf-essentials.zip
Archive: adf-essentials.zip
Label: JDEVADF_11.1.2.3.0_GENERIC_120914.0223.6276.1
inflating: adf-controller-security.jar
inflating: adf-share-security.jar
...
[adf-multikoop.rhcloud.com lib]\>
Now restart glassfish to grab the changes!
adf-multikoop.rhcloud.com ~]\> ./adf/repo/.openshift/action_hooks/stop
..
adf-multikoop.rhcloud.com ~]\> ./adf/repo/.openshift/action_hooks/start
..
Create a simple ADF 11.1.2.3 Application and copy it into the autodeploy folder
enpitmac:~ ak$ cd Workspace/enpit-base/development/enpit.sample/enpit.sample.gf.app1/deploy/
enpitmac:deploy ak$ scp enpit-sample-app1.ear <.....>@adf-multikoop.rhcloud.com:/var/lib/stickshift/<...>/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 ;)
WHAT'S NEXT
- Hopefully Oracle will unveil the Oracle Cloud for everyone who wants to run / try out ADF ;). Please ! http://cloud.oracle.com
REFERENCES
- OpenShift Client Tools: https://openshift.redhat.com/community/get-started#install_client_tools
- Glassfish on OpenShift: https://openshift.redhat.com/community/blogs/running-java-apps-in-the-cloud-with-glassfish-and-a-paas
- Shay Shmeltzer instruction for Glassfish Deployment: https://blogs.oracle.com/shay/entry/deploying_oracle_adf_applications_to
- Oracle Fusion Developers Guide for ADF 11.1.2.3
http://docs.oracle.com/cd/E35521_01/web.111230/e16182/appendix_glassfish.htm#ADFFD23812 - Oracle FMW Administration Guide for ADF 11.1.2.3 http://docs.oracle.com/cd/E35521_01/admin.111230/e16179/ap_glassfish.htm#BABIEADD