Install Oracle XE 11g, update APEX to 4.2.6 and runn Oracle REST Data Services with Tomcat server

Step 1. Install Oracle XE 11g

1. Download Oracle XE (oracle-xe-11.2.0-1.0.x86_64.rpm.zip) from Oracle official website. You need an account to do so.
2. unzip and enter the unzipped folder Disk1, run
sudo rpm -ivh oracle-xe-11.2.0-1.0.x86_64.rpm
3. configure oracle
/etc/init.d/oracle-xe configure
# provide port for Apex:8080
# port for database listener (1521) 
# password to be used for both SYS and SYSTEM users:tiger
# whether you’d like to have the database start automatically at system start:y
4. Edit ~/.bashrc file and add the following contents:
#ORACLE XE 11g paths
export ORACLE_SID=XE
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/xe
export ORACLE_TERM=xterm
export NLS_LANG=american_america.utf8
export TNS_ADMIN=$ORACLE_HOME/network/admin
export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export PATH=$ORACLE_HOME/bin:$PATH
and make the donfiguration take effect
.  ~/.bashrc
5. Now we have finished installing Oracle XE 11g on CentOS.

After fresh installing Oracle, when you run
 sqlplus / as sysdba 
, you might encounter
 ORA-01031: insufficient privileges.
[htang@centos6vm apex]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.2.0 Production on Tue Apr 14 10:35:45 2015
Copyright (c) 1982, 2011, Oracle.  All rights reserved.
ERROR:
ORA-01031: insufficient privileges 
 
Solution: Add dba group for your current session user.
usermod -a -G dba htang

Step 2. Follow my previous post here, to update Apex to 4.2.6

6. If You want to continue use Embedded PL/SQL Gateway (EPG), you are all set and stop here.

Step 3. Deploy Oracle REST Data Services on Tomcat 

Oracle REST Data Services is a Java EE-based alternative for Oracle HTTP Server and mod_plsql.
7. Install Tomcat if needed
su -
cd /etc/yum.repos.d
wget 'http://www.jpackage.org/jpackage50.repo' 
yum update
yum install tomcat6 tomcat6-webapps tomcat6-admin-webapps
/etc/init.d/tomcat6 start 
7.1 add admin account for Tomcat
/etc/tomcat6/tomcat-users.xml
#add the following line before </tomcat-users> tag
<user name="apex" password="apex123" roles="manager,admin,Manager,Admin" />
8. Shutdown Apex-EPG
sqlplus /nolog
connect sys as sysdba
#type in password
#run the following command
execute dbms_xdb.sethttpport(0);
9. prepare APEX_PUBLIC_USER account for installing Oracle rest Data Services
sqlplus / as sysdba
#then run
CREATE PROFILE UNLIMITED_PASSWORD_LIFETIME LIMIT
  SESSIONS_PER_USER DEFAULT
  CPU_PER_SESSION DEFAULT
  CPU_PER_CALL DEFAULT
  CONNECT_TIME DEFAULT
  IDLE_TIME DEFAULT
  LOGICAL_READS_PER_SESSION DEFAULT
  LOGICAL_READS_PER_CALL DEFAULT
  COMPOSITE_LIMIT DEFAULT
  PRIVATE_SGA DEFAULT
  FAILED_LOGIN_ATTEMPTS DEFAULT
  PASSWORD_LIFE_TIME UNLIMITED
  PASSWORD_REUSE_TIME DEFAULT
  PASSWORD_REUSE_MAX DEFAULT
  PASSWORD_LOCK_TIME DEFAULT
  PASSWORD_GRACE_TIME DEFAULT
  PASSWORD_VERIFY_FUNCTION DEFAULT;
#and run
alter user apex_public_user profile unlimited_password_lifetime account unlock;
alter user apex_public_user identified by apexpass;
 
10. download oracle oracle REST data Services from oracle which replaces oracle listener
unzip ords.2.0.9.224.01.05.zip -d ords
cd ords
#rename file ords.war to apex.war
#in order to use http://example.com:8080/apex instead of http://example.com:8080/ords
mv ords.war apex.war
#create ords configuration folder
sudo mkdir /u01/app/oracle/product/ords_config
#configure config.dir for ords
java -jar apex.war configdir /u01/app/oracle/product/ords_config/
#Sep 30, 2014 9:41:17 PM oracle.dbtools.common.config.cmds.ConfigDir execute
#INFO: Set config.dir to /u01/app/oracle/product/ords_config/ in: /home/htang/oracle/ords/apex.war
#verify config.dir
java -jar apex.war configdir
#Sep 30, 2014 9:41:30 PM oracle.dbtools.common.config.cmds.ConfigDir execute
#INFO: The config.dir value is /u01/app/oracle/product/ords_config/
11. make configure
sudo java -jar apex.war 
Outputs are:
Sep 30, 2014 9:41:39 PM oracle.dbtools.common.config.file.ConfigurationFolder logConfigFolder
INFO: Using configuration folder: /u01/app/oracle/product/ords_config/apex
Enter the name of the database server [localhost]:
Enter the database listen port [1521]:
Enter 1 to specify the database service name, or 2 to specify the database SID [1]:2
Enter the database SID [xe]:
Enter the database user name [APEX_PUBLIC_USER]:
Enter the database password for APEX_PUBLIC_USER:apexpass
Confirm password:apexpass
Enter 1 to enter passwords for the RESTful Services database users (APEX_LISTENER,APEX_REST_PUBLIC_USE same password as used for APEX_PUBLIC_USER or, 3 to skip this step [1]:2
Sep 30, 2014 9:42:10 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
12. change owner of configuration dir /u01/app/oracle/product/ords_config/ to Tomcat. Or you will see "FAIL - Application at context path /apex could not be started" in Tomcat manager page.
sudo chown tomcat:tomcat -R /u01/app/oracle/product/ords_config/
13. copy configured apex.war file into tomcat webapp folder and restart tomcat
sudo cp apex.war /var/lib/tomcat6/webapps/
copy image files from unpacked apex/images folder into tomcat webapps folder. Or you will encounter blank front page.
sudo mkdir /var/lib/tomcat6/webapps/i
sudo cp apex/apex/images/* /var/lib/tomcat6/webapps/i/
14. restart Tomcat and visit http://example.com:8080/apex/
sudo /etc/init.d/tomcat restart

[4/13/2015] 503-Service Unavailable and solution

 I noticed "Oracle Rest Data Service 503-Service Unavailable " error message when I try to connect to my Apex application. Further investigate Tomcat error log file at
/var/log/tomcat6/catalina.out
, from
 java.sql.SQLException: Exception occurred while getting connection: oracle.ucp.UniversalConnectionPoolException: Cannot get Connection from Datasource: java.sql.SQLException: ORA-28001: the password has expired 
, I realized that the error is caused by the expired password of user APEX_PUBLIC_USER. Solution 1. change password for user APEX_PUBLIC_USER.
alter user APEX_PUBLIC_USER identified by apexpass;
2. delete old configuration files and apex.war files from
 /u01/app/oracle/product/ords_config
and
/var/lib/tomcat6/webapps/
, then follow step 9 to reinstall restful data service.

We could also disable password expiration by doing: 
1. To alter the password expiry policy for a certain user profile in Oracle first check wich profile the user is in using:
select profile from DBA_USERS where username = '<username>';
If you want to previously check the limit you may use:
select resource_name,limit from dba_profiles where profile='<profile_name>';
Then you can change the limit to never expire using:
alter profile <profile_name> limit password_life_time UNLIMITED;

No comments:

Post a Comment

Datatable static image not found on the server

When you use ```datatables.min.css``` and ```datatables.min.js``` locally, instead of datatables CDN, you may have encountered that ```sort...