Install Apex 4.2 on Glassfish4 Server

This is my third time of writing how to install Apex, and each time there is a new element to the installation, much of it is the same, but there are some areas that are not documented or just  a little bit vague.

To complicate matters a little, I installed this on Oracle Linux, you would have though Oracle OS, Oracle Database and Oracle development studio would go hand in hand!!!


So as always you need to start with the base OS, this is just point and go, there really was no configuration on the Linux side to do.


The versions and stats for the install

Oracle Linux – Oracle Linux Server release 7.0

Kernel – 3.8.13-55.1.2.el7uek.x86_64

Database – XE 11.2.0

Apex – 4.2.6

Glassfish – 4.1

Apex Listener (now Oracle restful services 2.0)

Java JDK – java version “1.8.0_25”

One note that drove me mad for a day.

After thinking my config was wrong it dawned on me that it was the firewall, I normally suspect this and issue the normal command service iptables stop

I use this mainly just to get us working and then refine the rules later.


service iptables stop

Redirecting to /bin/systemctl stop iptables.service
Failed to issue method call: Unit iptables.service not loaded.

You would therefore think that there is no firewall, HOW wrong was I!!!!!!

Oracle Linux has adopted the systemd method of startup and dropped init.d

A quick command

systemctl list-unit-files

Showed the firewall service enabled

systemctl stop firewalld.service

You will need to read up on systemd as I will now start too. But this will get you a trouble free install to start with.


mkdir /opt/software

cd /opt/software

You will need to download the following :- (I downloaded the web version)


OK now let’s start

yum install unzip libaio
cd /opt/software/Disk1
rpm -i oracle-xe-11.2.0-1.0.x86_64.rpm

You will probably get this error

/var/tmp/rpm-tmp.ijRawr: line 186: bc: command not found

yum install bc

rpm -e oracle-xe-11.2.0-1.0.x86_64

There is a good chance that you will then run into this area

This system does not meet the minimum requirements for swap space. Based on the amount of physical memory available on the system, Oracle Database 11g Express Edition requires 2048 MB of swap space. This system has 1639 MB
of swap space. Configure more swap space on the system and retry the installation.

error: %pre(oracle-xe-11.2.0-1.0.x86_64) scriptlet failed, exit status 1
error: oracle-xe-11.2.0-1.0.x86_64: install failed

swapoff -a
rm -f /swapfile
dd if=/dev/zero of=/swapfile bs=2048 count=2097152
/sbin/mkswap /swapfile
/sbin/swapon /swapfile
/sbin/swapon -s


Now edit the fstab so that the existing swapfile is not mounted

vi /etc/fstab
#/dev/mapper/ol-swap swap swap defaults 0 0
cd /opt/software/Disk1
rpm -i oracle-xe-11.2.0-1.0.x86_64.rpm

Once installed you will get the following message

Executing post-install steps…
You must run ‘/etc/init.d/oracle-xe configure’ as the root user to configure the database.


OK before we try to configure the database there are a few errors that may occur if you do not follow the next commands.

For this example my server is called APEX01


To avoid this error

Specify the HTTP port that will be used for Oracle Application Express [8080]:

/etc/init.d/oracle-xe: line 362: netstat: command not found
Specify a port that will be used for the database listener [1521]:

/etc/init.d/oracle-xe: line 405: netstat: command not found

yum install net-tools

There are several issues that can cause this the host file and the hostname may need changing.
The hostname needs to be in the host file

I installed this on the Oracle linux and therefore the host was called localhost
We are going to name the server apex01

vi /ect/hostname

We now need to populate the hosts file so that the server knows where to find itself.

echo " apex01" >> /etc/hosts
echo "IP ADDRESS OF SERVER apex01" >> /etc/hosts

Rebooting is a safe bet here

OK now to configure Oracle

/etc/init.d/oracle-xe configure

Oracle Database 11g Express Edition Configuration
This will configure on-boot properties of Oracle Database 11g Express
Edition. The following questions will determine whether the database should
be starting upon system boot, the ports it will use, and the passwords that
will be used for database accounts. Press <Enter> to accept the defaults.
Ctrl-C will abort.

Specify the HTTP port that will be used for Oracle Application Express [8080]:Enter

Specify a port that will be used for the database listener [1521]:Enter

Specify a password to be used for database accounts. Note that the same
password will be used for SYS and SYSTEM. Oracle recommends the use of
different passwords for each database account. This can be done after
initial configuration:Enter Password
Confirm the password:Enter Password

Do you want Oracle Database 11g Express Edition to be started on boot (y/n) [y]:y

Starting Oracle Net Listener…Done
Configuring database…

To test the connection

ln -s /u01/app/oracle/product/11.2.0/xe/bin/sqlplus /usr/bin/sqlplus

If you ran sqplus from the command line you would get the following error

P2-0667: Message file sp1<lang>.msb not found
SP2-0750: You may need to set ORACLE_HOME to your Oracle software directory

To correct this you need to set the ORACLE_HOME

vi /etc/profile

Insert the following lines at the bottom

export ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe

You need to run the profile to get the variables

. /etc/profile

Note the space between . /

It is also worth adding these lines to the .bashrc file in the home directory


This will see if you have set the directory correctly

To see if you have Oracle working correctly then:

sqlplus sys@localhost as sysdba

Enter the password that you set at the start of the installation

This should give you a SQL> prompt

select sysdate from dual;

This will return today’s date

We need to change some parameters in Oracle

sqlplus sys/password@localhost as sysdba
service oracle-xe restart

We need to return to some Oracle configuration later.

Time to install the java-jdk

cd /opt/software
rpm -i jdk-8u25-linux-x64.rpm

Now to get Apex installed

cd /opt/software/apex
sqlplus sys/password@localhost as sysdba

The creation of this environment will be based on the table space being called apex, so we need to create the relevant tables space.

So at the SQL> prompt

create tablespace apex
 datafile '/u01/app/oracle/oradata/XE/apex.dbf' 
 size 32m 
 autoextend on 
 next 32m maxsize 2048m
 extent management local;


To actually install Apex, the command we will use is as follows :-

@@apexins tablespace_apex tablespace_files tablespace_temp images

So in our example we will use

@@apexins apex apex temp /i/

This will take around 60 minutes to install, depending on the size of your server.

Now we will set the password for the admin of the site


Enter a password for the ADMIN user Enter admin password that you want

We now need to set the passwords for some internal apex user accounts


The password expires,to prevent this behavior, create another profile in which the PASSWORD_LIFE_TIME
parameter is set to unlimited and alter the APEX_PUBLIC_USER and APEX_LISTENER accounts and assign it
to the new profile.

CREATE PROFILE unlimited_access LIMIT 
alter user APEX_PUBLIC_USER profile unlimited_access;
alter user APEX_LISTENER profile unlimited_access;


This is from the Installation guide and requires executing if you want to access Apex

Granting Connect Privileges
The following example demonstrates how to grant connect privileges to any host for
the APEX_040200 database user. This example assumes you connected to the
database where Oracle Application Express is installed as SYS specifying the SYSDBA

-- Look for the ACL currently assigned to '*' and give APEX_040200
-- the "connect" privilege if APEX_040200 does not have the privilege yet.
'connect') IS NULL THEN
'APEX_040200', TRUE, 'connect');
-- When no ACL has been assigned to '*'.
'ACL that lets power users to connect to everywhere',
'APEX_040200', TRUE, 'connect');

You should get the message

PL/SQL procedure successfully completed.

Commit complete.


There are other areas of Oracle that need manipulation, again taken from the install guide.

To find the job_queue_processes

SELECT VALUE FROM v$parameter WHERE NAME = 'job_queue_processes';

To set the value


Once the user and passwords and connection grants have been set we can exit from the SQL> screen


Now we need to setup the Glassfish element.

cd /opt/software
mv glassfish4 /opt/
cd /opt/glassfish4

Note sure what the score is here, but from previous notes on the install, it appears that if you delete the domain and recreate it, it limits the possibility of errors occurring ????

./asadmin delete-domain domain1
./asadmin create-domain domain1

Enter admin user name [Enter to accept default “admin” / no password]>admin

Enter the admin password [Enter to accept default of no password]>glasspassword
Enter the admin password again>

You should be presented with the following message :-
Using default port 4848 for Admin.
Default port 8080 for HTTP Instance is in use. Using 54137
Using default port 7676 for JMS.
Using default port 3700 for IIOP.
Using default port 8181 for HTTP_SSL.
Using default port 3820 for IIOP_SSL.
Using default port 3920 for IIOP_MUTUALAUTH.
Using default port 8686 for JMX_ADMIN.
Using default port 6666 for OSGI_SHELL.
Using default port 9009 for JAVA_DEBUGGER.
Distinguished Name of the self-signed X.509 Server Certificate is:
[CN=apex01,OU=GlassFish,O=Oracle Corporation,L=Santa Clara,ST=California,C=US]
Distinguished Name of the self-signed X.509 Server Certificate is:
[CN=apex01-instance,OU=GlassFish,O=Oracle Corporation,L=Santa Clara,ST=California,C=US]
Domain domain1 created.
Domain domain1 admin port is 4848.
Domain domain1 admin user is “admin”.
Command create-domain executed successfully.


Now we have it installed lets try to start the server and get the other bits configured

cd /opt/glassfish4/bin/
./asadmin start-domain

Hopefully you should get a message on screen

Waiting for domain1 to start ……

Successfully started the domain : domain1

domain Location: /opt/glassfish4/glassfish/domains/domain1

Log File: /opt/glassfish4/glassfish/domains/domain1/logs/server.log

Admin Port: 4848

Command start-domain executed successfully.

Just to test

Navigate to http://FQDN:4848 (where FQDN is your server name)
Login with the credentials that you specified when creating the domain

When you try to log in you will get this message

“Secure Admin must be enabled to access the DAS remotely.”

To remove this is issue you must enable remote access.

cd /opt/glassfish4/bin

Use “exit” to exit and “help” for online help.

asadmin> get secure-admin.enabled

Enter admin user name> admin
Enter admin password for user “admin”>


Command get executed successfully.

asadmin> enable-secure-admin

Enter admin user name> admin
Enter admin password for user “admin”>

You must restart all running servers for the change in secure admin to take effect.
Command enable-secure-admin executed successfully.

asadmin> stop-domain

Waiting for the domain to stop ….
Command stop-domain executed successfully.

asadmin> start-domain

Waiting for domain1 to start ……
Successfully started the domain : domain
domain Location: /u01/app/glassfish4/glassfish/domains/domain1
Log File: /u01/app/glassfish4/glassfish/domains/domain1/logs/server.log
Admin Port: 4848
Command start-domain executed successfully.

asadmin> exit

Try to log in again

If you are successful we need to add the Apex element of the installation

cd /opt/glassfish4/bin
./asadmin stop-domain
mkdir -p /opt/glassfish4/glassfish/domains/domain1/docroot/i
cp -r /opt/software/apex/images/* /opt/glassfish4/glassfish/domains/domain1/docroot/i
cd /opt/software
mkdir /opt/ords
mv /opt/ords
cd /opt/ords

Now to do a little configuration

One of the questions will be what is the database SID, if you are unsure then

sqlplus sys@localhost as sysdba;
select sys_context('userenv','db_name') from dual;

Because this is the XE database the SID is XE

OK this is an important bit, you will get you application working without doing this but the config files will end up in /tmp/apex, so issue the configdir command ensure you keep your files is a safe place.

mkdir /opt/apex
java -jar ords.war configdir /opt/apex

java -jar ords.war

Jan 21, 2015 2:27:07 PM oracle.dbtools.common.config.file.ConfigurationFolder logConfigFolder
INFO: Using configuration folder: /tmp/apex
Enter the name of the database server [localhost]:Enter
Enter the database listen port [1521]:Enter
Enter 1 to specify the database service name, or 2 to specify the database SID [1]:1
Enter the database SID [xe]:XE
Enter the database user name [APEX_PUBLIC_USER]:Enter
Enter the database password for APEX_PUBLIC_USER:Enter the password set previously
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_USER or, 3 to skip this step [1]:2
Jan 21, 2015 2:39:39 PM oracle.dbtools.common.config.file.ConfigurationFiles update
INFO: Updated configurations: defaults, apex, apex_al, apex_rt
Enter 1 if you wish to start in standalone mode or 2 to exit [1]:2

OK now we need to compile a war file, this file will be called i.war

java -jar ords.war static /opt/glassfish4/glassfish/domains/domain1/docroot/i

WAR Generation complete
WAR location : /opt/ords/i.war
Context path : /i
Static resources : /opt/glassfish4/glassfish/domains/domain1/docroot/i
Ensure the static resources are available at path: /opt/glassfish4/glassfish/domains/domain1/docroot/i


We are now ready to deploy the two packages i.war and ords.war

Navigate to http://FQDN:4848 (where FQDN is your server name)

Login with the credentials that you specified when creating the domain


Login Screen


You need to set the “Default Principal To Role Mapping” to enabled




Don’t forget to press the save button

This is from the Apex install guide

From the web console.

Select the realm to which to add your user (for example, file).

The Edit Realm page appears.

On the Edit Realm page, click the Manage Users button.


The File Users page appears.

On the File Users page, click New.



The New File Realm User page appears.

On the New File Realm User page, create an Admin user:

User ID – Enter the name of the Oracle Application Express Listener administrator:

User ID: adminlistener

Group List – Enter the role to which the user belong:

Group List: Admin

New Password – Enter a unique password.

Confirm New Password – Enter the password again.

Click OK.




Repeat the previous steps and create another user for the Oracle Application Express Listener manager, by specifying the following:

User ID: managerlistener

Group List: Manager

Click OK.




You should end up with two file users




Installation and configuration of applications

We now need to install the Oracle Rest Service that we downloaded earlier on and also the i.war that we compiled

On the navigation tree, click the Application node.

The Applications page displays.

Click the Deploy button.


The Deploy Applications or Modules page displays.

Choose the  “Local Packaged File or Directory That Is Accessible from GlassFish Server”

Enter the location of the odrs.war file, in our configuration that is /opt/ords/odrs.war

Type – Web Application

Context Root – odrs

Application name – odrs

Check enabled for everything

Description – Apex Listener





You need to deploy i.war in the same way

Enter the location of the odrs.war file, in our configuration that is /opt/ords/i.war

Type – Web Application


Application name – i

Check enabled for everything

Description – Apex



Access Oracle Application Express Listener Administration

Once you have completed the above steps and uploaded the odrs.war and i.war file you can now launch the application.

If all is OK you will be able to launch the apex development environment at



OK you should see a login screen.

We need to create some users and a workspace to start our development.



More about how you use Apex and workspace in the next post.




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s