Archive for the ‘Oracle Apex’ Category

How to install Oracle Apex 5.1 and deploy to Apache Tomcat Application Server on linux (RHEL 6.7)

Requirement was to have the Apex launched from Tomcat and not using Standalone Apex installation.

Following components are needed for this setup

1.Installation of Oracle Apex 5.1

Download it from
Mine is 5.1.4 English Language ONLY

2.Installation and configuration of Apache Tomcat 9.0.6

Download it from

2.1 Installation of Java JDK 9.0.1

Download it from

3.Installation and configuration of orace Rest Data service (ORDS 17.4)

Download it from

Oracle EE 11gR2 is already installed and configured. Mine was already installed don AIX 6.3 box.

1.By default Oracle Apex comes as bundled with Oracle EE is located in $ORACLE_HOME/apex.
Since I needed to install 5.1, I renamed the existing “apex” folder and kept the the downloaded the zipped file ( to some temp location on the server (/tmp/

2.unzipped the file to $ORACLE_HOME
$ unzip /tmp/ — this will create the new apex folder which

3.Create Tablespace in database for storing Apex MetaData
Login to Database as sysdba and issue below command to create a tablespace called “APEX”

CREATE TABLESPACE APEX DATAFILE ‘/d03/oracle/oradata/apex_01.dbf’

4. Now we need to install Apex 5.1. Change to $ORACLE_HOME/apex directory and login to SQL DB as sysdba
SQL> !pwd

SQL>@apexins.sql APEX APEX TEMP /i/
Here APEX is the TBS created in Step#2 and TEMP is the temporary tablespace.

Thank you for installing Oracle Application Express

Oracle Application Express is installed in the APEX_050100 schema.

The structure of the link to the Application Express administration services is as follows:
http://host:port/pls/apex/apex_admin (Oracle HTTP Server with mod_plsql)
http://host:port/apex/apex_admin (Oracle XML DB HTTP listener with the embedded PL/SQL gateway)
http://host:port/apex/apex_admin (Oracle REST Data Services)

The structure of the link to the Application Express development interface is as follows:
http://host:port/pls/apex (Oracle HTTP Server with mod_plsql)
http://host:port/apex (Oracle XML DB HTTP listener with the embedded PL/SQL gateway)
http://host:port/apex (Oracle REST Data Services)

timing for: Phase 3 (Switch)
Elapsed: 00:01:54.23
timing for: Complete Installation
Elapsed: 00:13:58.41

PL/SQL procedure successfully completed.

5. Connect again to the Database using “sysdba” and move to the same $ORACLE_HOME/apex location
and run apex_rest_config.sql

SQL> !pwd

SQL>@apex_rest_config.sql –> this will ask for password for APEX_LISTENER_USER & APEX_REST_PUBLIC_USER

Enter a password for the APEX_LISTENER user [] apex4demo
Enter a password for the APEX_REST_PUBLIC_USER user [] apex4demo

I kept the same password “apex4demo” for the entire installation.

After the successful run of the above script,
Synonym created.

Session altered.

PL/SQL procedure successfully completed

6.Now we need to stop the http port as the plan is to launch the Apex using Tomcat Apace and not standalone.
SQL> EXEC dbms_xdb.sethttpport(0);

PL/SQL procedure successfully completed.

7.Login to DB again as sysdba to unlock the user account.
SQL> alter user apex_public_user identified by apex4demo account unlock;

User altered.

SQL> alter user APEX_REST_PUBLIC_USER identified by apex4demo account unlock;

User altered.

8.Installation of Tomcat & Java JDK
This installation was done on another Linux server (RHEL 6.7) from where Apex will be launched.
Confirmed – Both the server (Apex hosting DB server and the tomcat server are able to talk to each other)

8.1 create a directory – /d01/apex
unzipped the tomcat apaeche zipped file & Java JDK
$ cd /d01/apex
$ tar xzf /tmp/apache-tomcat-9.0.6.tar.gz
$ tar xzf /tmp/jdk-9.0.1_linux-x64_bin.tar.gz

Modify the tomcat config file (/d01/apex/apache-tomcat-9.0.6/conf/server.xml) so as to use different port (default is 8080)
This is needed in my case as there is already another application running on tomcat on the default port.
Server port –> Changed to 8105 (Default is 8005)
Connector port –> Changed to 8181 (default is 8080)
Connector port (Define an AJP 1.3 Connector on port 8009) –> Changed to 8109 (Default is 8009)
Save the config file

Start the tomcat service
$startup/shutdown scritps are located in /d01/apex/apache-tomcat-9.0.6/bin
a) &

Before services are stopped/started, make sure to set following

export JAVA_HOME=/d01/apex/jdk-9.0.1
export CATALINA_HOME=/d01/apex/apache-tomcat-9.0.6
Check the catalina log ($CATALINA_HOME/logs/catalina.out) for any issue.

If the tomcat is successfully started, launch the IE and put the URL as –
http:/<server_name>:<port_number> (Pls remember it is 8181 for my case else default is 8080)

9. Install Oracle Rest Data service (ords)

9.1 Create a directory /d01/ords
9.2 Unzip the

$ cd /d01/ords
$ unzip /tmp/
Once unzipped, “/d01/ords/” directory will have a ‘war’ file called “ords.war”
By default, apex launc URL will look like – http://<server_name&gt;:8181/ords, but if you like to give some meaningful name in the URL, you MUST change the name of this ‘war’ file accordingly.

For my case, I wanted my URL to look like – http://<server_name&gt;:8181/demo,
renamed the ‘war’ file to “demo.war”.

9.3 Rename the parameter file (within /d01/ords/params) and update the settings as per the actual environment.

Default name –

Since the war file is renamed, it is mandatory to change the parameter file name as well –

Contents of parameter file
db.hostname=<Server name where the Database is installed>
db.port=<DB Port #>
db.servicename=<SID or Service Name of the database>
db.sid=<SID or Service Name of the database>
schema.tablespace.default=<Tablespace created in Step 1>
schema.tablespace.temp=<Existing TEMP Tablespace in the DB>
standalone.http.port=<Port number where the tomcat Apache is running>

9.4 Create a folder called “config” inside “/d01/ords”

9.4.i> Set the configuration directory to “config” for demo.war
$ export JAVA_HOME=/d01/apex/jdk-9.0.1
$ $JAVA_HOME/bin/java -jar demo.war configdir /d01/ords/config

Above command resulted in below error
java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
at java.base/java.lang.Class.getDeclaredFields0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredFields(

This is due to the fact – “JDK 9 has deprecated java.xml.bind module and has removed from default classpath” and hence to overcome the error, workaround is to
Use –add-modules to add module in classpath

Hence correct command
$ $JAVA_HOME/bin/java –add-modules java.xml.bind -jar alqd.war configdir /d01/ords/config-ords
Mar 26, 2018 4:03:26 PM
INFO: Set config.dir to /d01/ords/config in: /d01/ords/demo.war

9.5.Now execute the Oracle Rest Data service config script

$ cd /d01/ords
$ $JAVA_HOME/bin/java –add-modules java.xml.bind -jar demo.war

Below information are asked

Enter the name of the database server [localhost]: <Press Enter>;
Enter the database listen port [1521]: <Press enter if your port is 1521, if others then put the value and press enter>
Enter 1 to specify the database service name, or 2 to specify the database SID [1]: <Press Enter>
Enter the database service name:Demo (I have put DEMO my service name, please put your db service name)
Enter 1 if you want to verify/install Oracle REST Data Services schema or 2 to skip this step [1]: <Press Enter>
Enter the database password for ORDS_PUBLIC_USER:apex4demo
Enter the database password for sys: sys123
If using Oracle Application Express or migrating from mod_plsql then you must enter 1 [1]: <Press Enter>
Enter the PL/SQL Gateway database user name [APEX_PUBLIC_USER]: <Press Enter>
Enter the database password for APEX_PUBLIC_USER:apex4demo
Enter 1 to specify passwords for Application Express RESTful Services database users (APEX_LISTENER, APEX_REST_PUBLIC_USER) or 2 to skip this step [1]: <Press Enter>
Enter the database password for APEX_LISTENER: apex4demo
Enter the database password for APEX_REST_PUBLIC_USER: apex4demo
Enter 1 if you wish to start in standalone mode or 2 to exit [1]: 2

Requires SYS AS SYSDBA to verify Oracle REST Data Services schema.

Enter the database password for SYS AS SYSDBA:
Confirm password:

Retrieving information.
Mar 26, 2018 5:45:08 PM
INFO: Updated configurations: defaults, apex, apex_pu, apex_al, apex_rt
Installing Oracle REST Data Services version
... Log file written to /d01/ords/logs/ords_install_core_2018-03-26_174508_00856.log
... Verified database prerequisites
... Created Oracle REST Data Services schema
... Created Oracle REST Data Services proxy user
... Granted privileges to Oracle REST Data Services
... Created Oracle REST Data Services database objects
... Log file written to /d01/ords/logs/ords_install_datamodel_2018-03-26_174523_00352.log
... Log file written to /d01/ords/logs/ords_install_apex_2018-03-26_174524_00312.log
Completed installation for Oracle REST Data Services version Elapsed time: 00:00:16.538

10. Deploying oracle apex to Tomcat Apache
Copy the demo.war file from the directory /d01/ords and paste into the directory /d01/apex/apache-tomcat-9.0.6/webapps
11. Create a folder “i” inside /d01/apex/apache-tomcat-9.0.6/webapps
11.1 Copy the entire contents from $ORACLE_HOME/apex/images to this folder /d01/apex/apache-tomcat-9.0.6/webapps/i
login to the DB server where the apex is installed
$ cd $ORACLE_HOME/apex/images
$ scp * <user_name>@<Tomcat_Server>://d01/apex/apache-tomcat-9.0.6/webapps/i

12. Final step is to restart the tomcat apache service.

But before it is done, due to the fact ‘JDK 9 has deprecated java.xml.bind module and has removed from default classpath’, I had to modify the startup script so as to include this in the class path.

Modify $CATALINA_HOME/logs/

$ # Add the JAVA 9 specific start-up parameters required by Tomcat
JDK_JAVA_OPTIONS=”$JDK_JAVA_OPTIONS –add-modules java.xml.bind” ### Added to overcome the deployment error

Now restart the tomcat

13. Launch Apex URL – http://:8181/demo

Hope this helps. Happy reading and learning!

-Anand M

Categories: Oracle Apex Tags: , ,