Friday 17 June 2016

Setting up a standalone APEX Listener in Glassfish

I setup Glass fish on a development box a few weeks ago. My understanding of how Glassfish works and where it fits into the enterprise architecture picture is limited but I believe I have an idea of what it is: Glassfish is a free application server. It looks and feels, at least to me, like a lightweight Oracle 11g Middleware. The reason why Glassfish was needed is that the development team wanted to setup an APEX listener and that listener needed to be accessible to the outside world and hosted outside of the database. The database that is at the centre of this setup has APEX 4.2 installed in it.

My notes for setting up APEX are below.

1. Download Glassfish and the APEX Standalone Listener:

Glassfish server can be found here:
https://glassfish.java.net/download.html

Listener can be found here:
http://www.oracle.com/technetwork/developer-tools/rest-data-services/downloads/apex-listener-download-v205-2135981.html

*NOTE: The download locations can change from time to time, so for this post I used Apex Listener 2.0.5
I later learned that Oracle rebranded the listener to Oracle Restful Services. This note is focused on the old Apex Listener.

2. Install
Unzip Glassfish in a suitable location. I use E:\oracle\glassfish4. Glassfish works out the box so there is no installation required.

3. Start the default domain

E:\oracle\glassfish4\bin>asadmin start-domain
Waiting for domain1 to start ..................
Successfully started the domain : domain1
domain  Location: E:\oracle\glassfish4\glassfish\domains\domain1
Log File: E:\oracle\glassfish4\glassfish\domains\domain1\logs\server.log
Admin Port: 4848
Command start-domain executed successfully.

4. Set the admin password 
For now, I use "adminadmin"

E:\oracle\glassfish4\bin>asadmin --host localhost --port 4848 change-admin-password
Enter admin user name [default: admin]>admin
Enter the admin password> <TYPE ADMINADMIN>
Enter the new admin password> <TYPE ADMINADMIN>
Enter the new admin password again> <TYPE ADMINADMIN>
Command change-admin-password executed successfully.

5. Enable secure admin
E:\oracle\glassfish4\bin>asadmin --host localhost --port 4848 enable-secure-admin
Enter admin user name>  admin
Enter admin password for user "admin"> <TYPE ADMINADMIN>
You must restart all running servers for the change in secure admin to take effect.
Command enable-secure-admin executed successfully.

6. Setup the APEX.WAR file for glassfish.
For Glassfish to present an Apex Listener, all it needs is the APEX.WAR file. I navigate to the location of the WAR file located inside the unzipped listener folder.
I then configure the file and save it. I configure the listener to use directory E:\oracle\glassfish4\glassfish\domains\domain1\apex_config to contain its configuration information.
So, make the directory E:\oracle\glassfish4\glassfish\domains\domain1\apex_config before configuring the WAR file.

G:\apex_listener_2_0_5>java -jar apex.war configdir E:\oracle\glassfish4\glassfish\domains\domain1\apex_config
Apr 21, 2016 3:30:10 PM oracle.dbtools.common.config.cmds.ConfigDir execute
INFO: Set config.dir to E:\oracle\glassfish4\glassfish\domains\domain1\apex_config in: G:\apex_listener_2_0_5\apex.war

7. Configure the listener to point to one database
G:\apex_listener_2_0_5>java -jar apex.war setup
Apr 21, 2016 3:30:43 PM oracle.dbtools.common.config.file.ConfigurationFolder logConfigFolder
INFO: Using configuration folder: E:\oracle\glassfish4\glassfish\domains\domain1\apex_config\apex
Enter the name of the database server [localhost]:<GLASSFISH SERVER>
Enter the database listen port [1521]:1522
Enter 1 to specify the database service name, or 2 to specify the database SID [1]:2
Enter the database SID [xe]:<DATABASE SID>
Enter the database user name [APEX_PUBLIC_USER]:APEX_PUBLIC_USER
Enter the database password for APEX_PUBLIC_USER:
Confirm password:
Enter 1 to enter passwords for the RESTful Services database users (APEX_LISTENER,APEX_REST_PUBLIC_USER), 2 to use the same password as used for APEX_PUBLIC_USE
R or, 3 to skip this step [1]:1
Enter the database password for APEX_LISTENER:
Confirm password:
Enter the database password for APEX_REST_PUBLIC_USER:
Confirm password:
Apr 21, 2016 3:32:09 PM oracle.dbtools.common.config.file.ConfigurationFiles update
INFO: Updated configurations: defaults, apex, apex_al, apex_rt

8. Make the apex images directory available to the APEX.WAR file
These images are the ones found within the APEX database installation package.
On our development server, our /i alias is set to e:\apex422_images. So, I setup the war to point to the same location.

G:\apex_listener_2_0_5>java -jar apex.war static e:\apex422_images
WAR Generation complete
WAR location     : G:\apex_listener_2_0_5\i.war
Context path     : /i
Static resources : e:\apex422_images
Ensure the static resources are available at path: e:\apex422_images
on the server where the WAR is deployed

9. Upload the JAR file into glass fish.
Navigate to https://<GLASSFISH HOSTING SERVER>:4848





Enter the credentials selected earlier.
Once logged in, click the "Applications" link on the left. Once it opens in the right panel, click the "Deploy" button. You will presented with the screen below.




















Click the "Choose File" button and locate the WAR. Once selected, click "OK"

This will load the JAR file into the Glassfish framework.

9. Stop and start the domain
E:\oracle\glassfish4\bin>asadmin stop-domain
Waiting for the domain to stop .
Command stop-domain executed successfully.

E:\oracle\glassfish4\bin>asadmin start-domain
Waiting for domain1 to start ...........................................
Successfully started the domain : domain1
domain  Location: E:\oracle\glassfish4\glassfish\domains\domain1
Log File: E:\oracle\glassfish4\glassfish\domains\domain1\logs\server.log
Admin Port: 4848
Command start-domain executed successfully.

10. Test glass fish and the new glasshfish administration page.

It seems that Glassfish piggy backs off port 8080 - the other webserver port when 80 is taken.
The glassfish administration console presents itself on port 4848.
To logon to the Glassfish administration console, use the credentials supplied in the APEX setup.

Test Apex

http://<GLASSFISH HOSTING SERVER>:8080/apex/apex_admin



No comments:

Post a Comment