Saturday, August 15, 2015

Installing APEX5 with ORDS3 on Apache-Tomcat

I am moving this blog to my own word-press site. So all new blogs and updates will be published there. Please use this new link.




I was facing few problems like 404 page not found etc. so after going through the documentation and OTN forum I finally succeeded in setting up the Oracle XE+ Apex 5 + ORDS 3+Tomcat on my laptop. I thought of sharing it to everyone.

I assume that you have installation files of following with you.


  • Oracle XE 11g installation files
  • APEX 5.0.1 zip file
  • ORDS 3.0.1.177.18.02.zip
  • apache-tomcat-8.0.22.zip
  • Java Run time 


Here are the different directory/ paths that I have used, in case you have a different path for any installation make changes accordingly
.
  • Oracle XE - c:\oralexe
  • APEX set up files - C:\Tools\apex501

Step 1 – Install Oracle XE

I am not going through the installation of Oracle XE, the only thing you need to know is system password.
For sqlplus - in most cases you can also log in as sysdba without password in sqlplus using “/ as sysdba”

Step 2 – Install APEX


  1. Unzip the apex_5.0.1_en.zip file in C:\Tools\apex501
  2. Go to command prompt, Change directory to C:\Tools\apex501
  3. Log on to database using sqlplus as sysdba
  4. Create necessary Table spaces using following commands

    CREATE TABLESPACE APEX DATAFILE 'C:\oraclexe\app\oracle\oradata\XE\APEX.DBF' SIZE 1200M EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;

    CREATE TABLESPACE APEX_FILES DATAFILE 'C:\oraclexe\app\oracle\oradata\XE\APEX_FILES.DBF' SIZE 300M EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;
  5.            Finally start the apex installation using 

@apexins APEX APEX_FILES temp /i/


The installation will take 15 minutes to 30 minutes depending on your PC configuration. Make sure that you see these lines finally, if you see this means your APEX installation was successful.
Session altered.
timing for: Complete Installation
Elapsed: 00:12:36.80
PL/SQL procedure successfully completed.
PL/SQL procedure successfully completed.
1 row selected.
Disconnected from Oracle Database 11g Express Edition Release 11.2.0.2.0 – Production

Step 3 Install JRE

Install JRE and note down the path. On my laptop it is
C:\Program Files (x86)\Java\jre1.8.0_45\bin\java.exe

Step 4 Install Apache Tomcat server

Download latest version, I am using apache-tomcat-8.0.22.exe as of this writing. When you run the
Set-up make sure to use “Run as administrator” option.

1.       On Welcome screen click next
2.       Next screen is about the license agreement, click on “I Agree” button
3.       On the “Choose Options” button, again there is no need to change any selections so just click next button.
4.       The next screen is configuration. Here you need to specify the ports, the HTTP port is where the apex will be configured, I have used 8180 it was used by some other server on my laptop but you can use default 8080 if there is no conflict.




Also enter user administrator name in user name box and set password, make sure to note it down so you don’t end up missing it. Once done click next.


5.       The next screen is “Java Virtual Machine”. Apache set up will look for Java Virtual machine, most probably it will detect the java and populate the path properly, if not then refer step 3, and enter the java home like this  
C:\Program Files (x86)\Java\jre1.8.0_45
Then click next.
6.       Next screen is “Choose Install Location”, no change needed. So click next.
7.   Click on install, finally you will see the “completing wizard” screen like this.




Keep the “Run Apache Tomcat” selected and click Finish.
Tomcat server will now start showing the start  progress.




When it is complete you will see the icon in the taskbar like this.




Check if the server is running, open browser and point to locahost:8180 , if you get following page then it means all is fine. 





Step 5 Prerequisites before setting up ORDS

Login in into database using system as sysdba
  
1.       EXEC DBMS_XDB.SETHTTPPORT(0);
Confirm if this is 0.
SELECT DBMS_XDB.GETHTTPPORT FROM DUAL;

2.       Unlock APEX_PUBLIC_USER account and set the new password
ALTER USER APEX_PUBLIC_USER ACCOUNT UNLOCK;
ALTER USER APEX_PUBLIC_USER identified by secret;
ALTER USER APEX_PUBLIC_USER identified by secret;
3.       Unlock APEX_REST_PUBLIC_USER  and set the password
ALTER USER APEX_REST_PUBLIC_USER ACCOUNT UNLOCK;
ALTER user APEX_REST_PUBLIC_USER identified by secret;

Step 6 ORDS Configuration.


1.   Extract the ORDS zip file in C:\Tools\ORDS

2.   Make a directory to hold the configuration. If you have any failures during the installation, remember to delete the contents of this directory before trying again.

C:\Tools\ORDS-Config

3.   Edit the following file
C:\Tools\ORDS\params\ords_params.properties

And add following entries, please change according to your set up but if you are using default set up then this should be same. If required changed according to your set up.
db.hostname=localhost
db.port=1521
db.servicename=XE
db.sid=
db.username=APEX_PUBLIC_USER
migrate.apex.rest=false
rest.services.apex.add=
rest.services.ords.add=true
schema.tablespace.default=APEX
schema.tablespace.temp=TEMP
standalone.http.port=8180
standalone.static.images=
user.tablespace.default=USERS
user.tablespace.temp=TEMP

   Then set up the config directory using following command,


Note : For following command your Firewall might intervene

“C:\Program Files (x86)\Java\jre1.8.0_45\bin\java.exe" -jar C:\Tools\ORDS\ORDS.war configdir C:\Tools\ORDS-Config

The above command will end with this message

INFO: Set config.dir to C:\Tools\ORDS-Config in: C:\Tools\ORDS\ords.war

     Configure ORDS using the following command.


 For simplicity in all the steps below wherever a password is asked , I have entered secret, you can use different passwords if you wish to and yes this is not recommended for production.

“C:\Program Files (x86)\Java\jre1.8.0_45\bin\java.exe" -jar C:\Tools\ORDS\ORDS.war

Enter the database password for ORDS_PUBLIC_USER: secret
Confirm password:secret
Enter 1 if you want to use PL/SQL Gateway or 2 to skip this step [1]:1
Enter the database password for APEX_PUBLIC_USER:secret
Confirm password:secret

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]:1
Enter the database password for APEX_LISTENER:secret
Confirm password:secret
Enter the database password for APEX_REST_PUBLIC_USER:secret
Confirm password:secret
Aug 14, 2015 9:06:30 PM oracle.dbtools.common.config.file.ConfigurationFilesBase update
INFO: Updated configurations: defaults, apex, apex_pu, apex_al, apex_rt
Aug 14, 2015 9:06:30 PM oracle.dbtools.rt.config.setup.SchemaSetup install
INFO: Oracle REST Data Services schema version 3.0.1.177.18.02
Enter 1 if you wish to start in standalone mode or 2 to exit [1]:2


Step 7 Deploy the war file to tomcat server.


Copy Ords.war file to C:\Program Files\Apache Software Foundation\Tomcat 8.0\webapps

Once you copy the war file, Tomcat will expand it and create ords folder in webapss. There is no action for you but this is something you need to know, in case anything goes wrong in future as a clean-up you can delete it.

Step 8- Copy Images folder.


Copy content of imgaes folder
C:\Tools\apex501\images

to C:\Program Files\Apache Software Foundation\Tomcat 8.0\webapps\i folder. ( Note the folder name is “i”)

Step 9 Check the instance is running.


Go to localhost:8180/ords/apex

Step 10 Reset the admin password.


  1. Goto command prompt and change folder to  C:\Tools\apex501
  2. log in to oracle as sysdba
  3. type @apxchpwd.sql and hit enter , enter the new password as directed.
  4. Go to http://localhost:8180/ords/apex_admin
  5. Enter user name and password.


You are into APEX as an instance administrator, create workspaces and users as required.
Happy APEXing !


12 comments:

Vitek said...

Hi,

great tut.
I had to run in addition apex_rest_config.sql, cause user APEX_REST_PUBLIC_USER was not created. Is that missing in the tutorial, or did I miss anything?

Thanks
Vitek

JJ said...

@vitek: Yes, you need to run apex_rest_config.sql separately. You didn't miss anything.

Enrique Flores said...

Thank you so much! Very helpful

bbmm7th said...

hey thanks for the instructions, they're a nice addendum to the docs, for sure!

Have a question though:
When I go to the APEX url (http://machine:port/ords/) I'm getting this message:

There are issues with the configuration of the Static Files in your environment. Please consult the "Configuring Static File Support" section in the Application Express Installation Guide.

I can click past the message and get in to APEX.

I've gone through those docs a bunch - I have REST installed and active. Just to make sure the REST DB ids are ok, I reset their passwords like so:
Java -jar ords.war user APEX_LISTENER
Java -jar ords.war user APEX_REST_PUBLIC_USER

also, via the APEX Admin login, Manage Instance, Security
I've set RESTful access= Yes.

..and yet I still get that "Static file" message. Any thoughts?

Unknown said...

Hi Sanjeev,

I've followed all the instructions (apex 5) however I'm unable to get pass this error, I keep getting this message, it works in standalone


There is a problem with your environment because the Application Express files have not been loaded. Please verify that you have copied the images directory to your application server as instructed in the Installation Guide. In addition, please verify that your image prefix path is correct. Your current path is /i/ (it should contain both starting and ending forward slashes, such as the default /i/). Use the SQL script reset_image_prefix.sql if you need to change it.

Anonymous said...

I have a blank page after trying to access on : http://localhost:8180/ords/f?p=4550:10:9497428862000. Need a help !!!

Nagendra Reddy said...


Thank you for awesome post on Installing APEX5 with ORDS3 on Apache-Tomcat with useful screen shots.
Regards,
Apache tomcat Training.

Sameer said...

Hi Sanjeev,

Thanks a lot for the great post! It did save me lots of time and effort. One point, though, we must set the standalone.use.https=false as we are using Tomcat. I faced issues without this, but as soon as I set it to false it went smoothly.

I also need some guidance.

In Apex we can develop different applications in different workspaces and each of workspace can point to a different Oracle Schema. I wish to have different applications running in different workspaces. I want to configure Tomcat+ORDS so that different applications hosted in different workspaces.

I have ensured that all the schemas and workspaces are completely isolated so that data security and isolation are maintained.

Can you please guide me how we can configure Tomcat and ORDS to achieve same?

I have come across many articles that describe configuring different DATABASES but none on configuring different applications on same database.

Thanks a lot.

Have a great Day!

Sammeer

Sameer said...

Hi Sanjeev,

Thanks a lot for the great post! It did save me lots of time and effort. One point, though, we must set the standalone.use.https=false as we are using Tomcat. I faced issues without this, but as soon as I set it to false it went smoothly.

I also need some guidance.

In Apex we can develop different applications in different workspaces and each of workspace can point to a different Oracle Schema. I have different applications running in different workspaces. I want to configure Tomcat+ORDS so that different applications hosted in different workspaces [can be accessed by users. ] - missed this part in earlier post :)!

I have ensured that all the schemas and workspaces are completely isolated so that data security and isolation are maintained.

Can you please guide me how we can configure Tomcat and ORDS to achieve same?

I have come across many articles that describe configuring different DATABASES but none on configuring different applications on the same database.

Thanks a lot.

Have a great Day!

Sammeer

Anonymous said...

i am getting some error, after uploaded some images in shared component-static application files area, i am not able to access those files.. and also 404 file not found error is raising.
Thanks

csenthilmurugan said...

thanks a lot, this is very useful information, working fine. have a great day

Anonymous said...

Thank you very much for this article! We've tried several times deploying it following the ambiguous documentation from Oracle (do NOT expand the downloaded ords .zip file into the Tomcat webapps folder and then try to configure it)
You've made our Apex lives much easier!