Recently I’ve been installing the OATOA (Oracle APEX on Tomcat with ORDS behind Apache) stack a number of times on both Oracle Linux 7 and CentOS7.

In the past this was no problem, Tomcat came up and a request to http://myserver:8080/ords/ gave me the expected APEX login screen.

However since Oracle Linux 7 and CentOS7, it seemed that Tomcat started before it could find the Oracle database. A simple restart of the tomcat service would do the trick. On my virtual machine (recently switched from VirtualBox to parallels btw) meant for doing presentations no problem at all.

systemctl restart tomcat

Now I’m playing around with “droplets” at DigitalOcean, just another name for virtual servers in my opinion, but they have great features at a reasonable price. Take a look: https://m.do.co/c/187c0416a2b3.

But my droplets showed the same behaviour as my parallels virtual machine. I first had to restart tomcat to get a working system.

You all should know that I’m not a linux guru (really I’m not), so broke my brains about this for a looooong time.

Yesterday I finally managed to get this working. The idea is to make the tomcat start-script wait until it can see “something” on port 1521 (the db listener) and only then continue to start.

Open the file /usr/libexec/tomcat/server

nano /usr/libexec/tomcat/server

now add some lines of code _before_ the line that starts with MAIN_CLASS like this:

#!/bin/bash
. /usr/libexec/tomcat/preamble
# .=.=.=.=.= START Make tomcat wait on oracle .=.=.=.=.=
i=1
while netstat -lnt | awk ‘$4 ~ /:1521$/ {exit 1}’0
do
  sleep 10
  let i+=1
  if [ “$i” -gt “5” ]
  then
    break    #Abandon the loop.
  fi
done
# give Oracle some slack to also start the database
sleep 10
# .=.=.=.=.= END Make tomcat wait on oracle .=.=.=.=.=

MAIN_CLASS=org.apache.catalina.startup.Bootstrap

add the obvious lines to your script.

What is happening?

The line “netstat -lnt | awk …” tries to find the string “:1521” in the result of a “netstat -lnt” command. This would indicate that something is listening on that port. In our case it will be the Oracle Listener.

If it does not find an open port 1521, it will sleep for 10 seconds, increment a counter (“i”) by 1 and do the loop again. The loop will loop a maximum of five times to prevent an endless loop.

After the loop completes we give the Oracle database another 10 seconds to get started.

That should do the trick. It does for me (I use the same code at digitalocean as well as my parallels virtual linux server.

I’m sure linux must have some system in place that could do the trick as well (make one service dependable on the other) but I haven’t found an easy one to use. If someone could help me out here, feel free to leave a comment.

Regards,

Richard

Watching our visitors and how they arrive on warp11.com I cam across this page:

http://krisrice.blogspot.com/2010/12/listener-startupshutdown-script.html

definately worthwile caching… here we go:

Kris gives a script, which I altered a little bit.

#!/bin/sh
#
#
# chkconfig: 2345 80 05
# description: This is a program that is responsible for taking care of
# starting the apex-listener as a service. 
#
# processname: apxlistener
# Red Hat or SuSE config: /etc/sysconfig/apxlistener
# Debian or Ubuntu config: /etc/default/apxlistener
#
. /etc/rc.d/init.d/functions
NAME="Oracle Application Express Listener"
JAVA="/usr/java/jdk1.7.0_04/bin/java"
APEX_LISTENER_HOME="/u01/app/oracle/product/1.1.3/apex-listener"
APEX_IMAGES="/u01/app/oracle/product/4.1/apex/images/"
LOGFILE="$APEX_LISTENER_HOME/apex_listener.log"
PIDFILE="$APEX_LISTENER_HOME/apex_listener.pid"

start() {
        echo -n "Starting $NAME: "
        if [ -f $PIDFILE ]; then
                PID=`cat $PIDFILE`
                echo APEX Listener already running: $PID
                exit 2;
        else
            nohup $JAVA -Dapex.home="$APEX_LISTENER_HOME/tmp.apxlistener" -Dapex.images="$APEX_IMAGES" -Dapex.port=8080 -jar "$APEX_LISTENER_HOME/apex.war" 2>&1 > $LOGFILE  &
            RETVAL=$!
            echo Started PID: $RETVAL
            echo
            echo $RETVAL >>$PIDFILE
            return $RETVAL
        fi

}

status() {
        echo -n "Status $NAME: "
        if [ -f $PIDFILE ]; then
                PID=`cat $PIDFILE`
                echo APEX Listener already running: $PID
                ps -ef | grep $PID
        else
                echo APEX Listener not running
        fi
}

stop() {
        if [ -f $PIDFILE ]; then
                PID=`cat $PIDFILE`
                echo -n "Shutting down $NAME PID:$PID"
                echo
                kill $PID
                rm -f $PIDFILE
        else
                echo APEX Listener not running
        fi
        return 0
}

log() {
        tail -f $LOGFILE
}

info() {
    echo Before first use you must run the command below manually to initiate the service.
    echo 
    echo $JAVA -Dapex.home="$APEX_LISTENER_HOME/tmp.apxlistener" -Dapex.images="$APEX_IMAGES" -Dapex.port=8080 -jar "$APEX_LISTENER_HOME/apex.war"
    echo 
}

case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    status)
        status
        ;;
    restart)
        stop
        start
        ;;
    log)
        log
        ;;
    info)
        info
        ;;
    *)
        echo
        echo "Usage:  {start|stop|status|restart|log|info}"
        echo
        info
        exit 1
        ;;
esac
exit $?

You should edit highlighted lines:
JAVA: the location of your JDK. be advised the minimum version your listener needs
APEX_LISTENER_HOME: the location the listener uses to store its config files
APEX_IMAGES: the location of the apex images directory

Create the file as /etc/init.d/apxlistener

Now set it as executable

chmod a+x /etc/init.d/apxlistener

add it to the startup-list:

chkcondig --add apxlistener
chkconfig apxlistener on

Now we’re allmost there. The listener needs a console to do the initial configuration. If you would start the service as is, it will not have a console.

I added an option “info” that echoes the commandline the service will use:

so.. execute:

/etc/init.d/apxlistener info

will give you something like this:

Before first use you must run the command below manually to initiate the service.

/usr/java/jdk1.7.0_04/bin/java -Dapex.home=/u01/app/oracle/product/1.1.3/apex-listener/tmp.apxlistener -Dapex.images=/u01/app/oracle/product/4.1/apex/images/ -Dapex.port=8080 -jar /u01/app/oracle/product/1.1.3/apex-listener/apex.war

execute that line in your console, it will ask for two usernames ( I used “admin” in both cases) and passwords.

Enter them as requested after which you can go to http://yourserver:8080/apex/listernerConfigure

Here you can enter your details as described in the apex listener.

after a reboot the listener should start automatically.

Hi,

I recently installed a new server (mainly by using the installation guide you can find in the menu).

I think this needs an extra step, since I wasn’t able to send out emails from that system using Apex.
In the email-queue it kept saying: ORA-24247: network access denied by access control list (ACL)

A quick “Google”, I ended up here : http://blogs.oracle.com/pankaj/entry/how_to_get_mail_working_with_a

So I needed to execute something (read the blog), I did that as SYS:

<EDIT 12 sep 2011>
Please adjust the name of your apex schema in the code below, by adding / removing the remarks for the t_apex_user variable within the declare section of the code.
</EDIT>

<EDIT 29 mar 2013>
I altered the script into a more generic thing. It now takes a few variables:
t_apex_user contains the user for which you need to grant.
t_hostname is the host invloved (this can be ‘*’)
t_new_acl_name holds the name of the ACL in case a new ACL must be created
t_new_acl_descr is the description for this ACL
This makes this into a more generic ACL script, not only for opening up email for the apex user
</EDIT>

declare
  t_acl_path varchar2(4000);
  t_acl_id raw(16);
--  t_apex_user varchar2(30) := 'APEX_030200';
--  t_apex_user varchar2(30) := 'APEX_040000';
  t_apex_user varchar2(30)       := 'SPELEN';
  t_hostname  varchar2(2000)     := 'accounts.google.com';
  t_new_acl_name varchar2(2000);
  t_new_acl_descr varchar2(2000) := 'ACL that lets power users to connect to maps.google.com';
begin
  -- Look for the ACL currently assigned to '*' and give t_apex_user
  -- the "connect" privilege if t_apex_user does not have the privilege yet.
  
  if t_hostname = '*' then
    t_new_acl_name := 'power_users.xml';
  else
    t_new_acl_name := t_hostname || '.xml';
  end if;

  select acl
  into   t_acl_path
  from   dba_network_acls
  where  host = t_hostname
    and  lower_port is null
    and  upper_port is null;

  -- Before checking the privilege, make sure that the ACL is valid
  -- (for example, does not contain stale references to dropped users).
  -- If it does, the following exception will be raised:
  --
  -- ORA-44416: Invalid ACL: Unresolved principal t_apex_user
  -- ORA-06512: at "XDB.DBMS_XDBZ", line ...
  --
  select sys_op_r2o(extractvalue(p.res, '/Resource/XMLRef'))
  into   t_acl_id
  from   xdb.xdb$acl a
  ,      path_view p
  where  extractvalue(p.res, '/Resource/XMLRef') = ref(a)
    and  equals_path(p.res, t_acl_path) = 1;

  dbms_xdbz.validateacl(t_acl_id);
  if dbms_network_acl_admin.check_privilege(t_acl_path, t_apex_user, 'connect') is null
    then
      dbms_network_acl_admin.add_privilege(t_acl_path, t_apex_user, true, 'connect');
  end if;

  commit;

exception
  -- when no acl has been assigned to '*'.
  when no_data_found
    then
      dbms_network_acl_admin.create_acl(t_new_acl_name, t_new_acl_descr, t_apex_user, TRUE, 'connect');
      dbms_network_acl_admin.assign_acl(t_new_acl_name, t_hostname);
end;

I had to replace the “FLOWS_030000” by “APEX_040000” in Pankaj’s script. After this everything worked like a charm.

This is post 7 in the Fully Freeware APEX environment series. The post will cover the configuration of the Oracle HTTP server.

Please mention, that I’m not fully aware about the license restrictions on the Oracle HTTP server. What I heard is that if you use it for an APEX installation and install it physically on the same box as the Oracle database server there is no license fee. But please correct me if I’m wrong.

Information has been taken from

  • The APEX installation guide

Unlocking the APEX public user account

Unlocking and chinging its password:

connect system
alter user apex_public_user account unlock;
alter user apex_public user identified by secret_password;

Unzip the apex distribution

I may have a crazy directory structure, but this is what I understood from the Oracle standards:

su
mkdir -p /u01/app/oracle/product/4.0.2/
chmod 777 /u01/app/oracle/product/4.0.2/
unzip apex_4.0.2.zip -d /u01/app/oracle/product/4.0.2/

Loading the mod_plsql module

Loading the mod_plsql module into the (apache) server is as easy as editing a text-file. The key off-course is what text to edit:

If you used the directory I proposed in step VI, then the httpd.conf should be edited as follows:

su
export OHS=/u01/app/oracle/product/11.1.1/ofm
gedit $OHS/Oracle_WT1/instances/instance1/config/OHS/ohs1/httpd.conf

Add these lines at the end of the file:

LoadModule plsql_module "${ORACLE_HOME}/ohs/modules/mod_plsql.so"
include /u01/app/oracle/product/11.1.1/ofm/Oracle_WT1/ohs/conf/mod_plsql/*.conf

Save the file.

Configure the dads.conf

The dads.conf holds the information apex uses to log in into the database. Open it and edit:

gedit /u01/app/oracle/product/11.1.1/ofm/Oracle_WT1/ohs/conf/mod_plsql/dads.conf

The file should look like this:

# ============================================================================
#                     mod_plsql DAD Configuration File
# ============================================================================
# 1. Please refer to dads.README for a description of this file
# ============================================================================ 

# Note: This file should typically be included in your plsql.conf file with
# the "include" directive.

# Hint: You can look at some sample DADs in the dads.README file

# ============================================================================ 

Alias   /i/               "/u01/app/oracle/product/4.0.2/apex/images/"
AddType text/xml          xbl
AddType text/x-component  htc

<Location /apex>
 Order                          deny,allow
 PlsqlDocumentPath              docs
 AllowOverride                  None
 PlsqlDocumentProcedure         wwv_flow_file_manager.process_download
 PlsqlDatabaseConnectString     localhost:1521:XE ServiceNameFormat
 PlsqlNLSLanguage               AMERICAN_AMERICA.AL32UTF8
 PlsqlAuthenticationMode        Basic
 SetHandler                     pls_handler
 PlsqlDocumentTablename         wwv_flow_file_objects$
 PlsqlDatabaseUsername          APEX_PUBLIC_USER
 PlsqlDefaultPage               apex
 PlsqlDatabasePassword          parsingschemapasswd
 PlsqlRequestValidationFunction wwv_flow_epg_include_modules.authorize
 Allow from all
</Location>

Please have a look and correct the following directives:

  • PlsqlDatabaseConnectString
  • PlsqlDatabasePassword (pay attention. case is important)

Now we must (re-)start the OHS:

su
ln -s /u01/app/oracle/product/11.1.1/ofm/Oracle_WT1/instances/instance1/bin/opmnctl /bin/opmnctl
exit
opmnctl stopall
opmnctl startall

This piece of script also creates a symbolic link in /bin/ to the OHS management program “OPMNCTL”. We will use this later on to make OHS start automatically.

Automating the startup process

We’d like the OHS to start automatically when the server boots.

Create a file /etc/init.d/ohs

#!/bin/bash
#
# chkconfig: - 91 35
# description: Starts and stops Oracle HTTP Server. 

# Source function library.
. /etc/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

prog=$"Oracle HTTP server"

start() {
    echo -n $"Starting $prog: "
    /bin/opmnctl startall>nul:
}

stop() {
    echo -n $"Shutting down $prog: "
    /bin/opmnctl stopall>nul:
}
status() {
    /bin/opmnctl status
}

# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  restart|reload)
	stop
        echo ""
	start
        echo ""
	;;
  status)
	status
	;;
  *)
	echo $"Usage: $0 {start|stop|restart|status}"
	exit 1
esac

Now the server is controllable by:

  • /etc/init.d/ohs start
  • /etc/init.d/ohs stop
  • /etc/init.d/ohs restart
  • /etc/init.d/ohs status

This can then be easily be automated:

su
/sbin/chkconfig --add ohs
/sbin/chkconfig ohs on

Et voila! we’re be able to restart the box. OHS should now start automatically.

Obfuscating the password in dads.conf

Plain text passwords in plain textfiles is obviously not a good idea. The password in dads.conf can be obfuscated as follows:

This is post 6 in my series about a fully freeware APEX installation:

Information has been taken from

Shut down EPG

The EPG is still running. To shut it down, open SQL*plus:conn

conn system
execute dbms_xdb.sethttpport(0);
exit

Prerequisits

Make sure your system has enough memory (2 Gigs or more)

We need to alter the system a bit:

Oracle

Start SQL*plus as system

alter system set PROCESSES=500 scope=SPFILE;
alter system set open_cursors=500 scope=SPFILE;
alter system register;

Kernel Parameters

Open up /etc/security/limits.conf in gedit.

Add these lines just before “# End of file”

# tbv oracle soa suite 11g
*    hard    nofile  4096
*    soft    nofile  4096

Install packages

And we need to install some extra packages:

su
yum install compat-libstdc++-33
yum install elfutils-libelf
yum install elfutils-libelf-devel
yum install gcc-c++
yum install glibc-devel
yum install libaio-devel
yum install libstdc++-devel
yum install sysstat

Instaling the WebTier

Unzip the ofm_webtier zip into a separate folder:
Make sure you’re not root. The installer will stop.

su
unzip ofm_webtier_linux_11.1.1.2.0_64_disk1_1of1.zip -d webtier
cd webtier/Disk1
./runInstaller

The installer will start:

Click “OK”, a confirmation dialog appears:

Execute the proposed script in a separate terminal:

su
/home/apex/oraInventory/createCentralInventory.sh

Now the installer will start:

Click “Next”

Choose “Install and Configure” and click “Next”

All should be Okay since we did the prerequisites earlier. Click “Next”

I used “/u01/app/oracle/product/11.1.1/ofm” (created it first in a separate rooted terminal).

su
mkdir -p /u01/app/oracle/product/11.1.1/ofm
chmod 777 /u01/app/oracle/product/11.1.1/ofm

Click “Next”.

Configure Components

We’re only installing the HTTP server. Uncheck all  other checkboxes (including the “Associate Components”) and click “Next”.

Keep the defaults: “Next”

Keep the defaults: “Next”

Fill in your credentials or keep everything empty (and uncheck the checkbox)

Click “Install”

After the installer completes:

Click “Next”

Note the URL’s mentioned

  • Oracle HTTP server URL: http://localhost:7777
  • Oracle HTTP server SSL URL: http://localhost:4443

Click “Finish”

Now we need to configure the HTTP-Server. This I’ll cover in the next post.

This is part 3 of my series on a fully freeware APEX environment on CentOS:

This post consists of 3 parts:

  • Install Java
  • Glassfish preparations
  • Install GlassFish
  • Configure Glassfish (part 3a)

Information has been taken from:

Here we go…

Install Java

CentOS allready comes with java pre-installed:

/usr/bin/java -> /etc/alternatives/java -> /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java

Glassfish however requires JDK 6:

su -c "yum install java-1.6.0-openjdk"
su -c "yum install java-1.6.0-openjdk-devel"

There might be a message at step openjdk that the package is allready installed.

After install we need to figure out the JAVA_HOME. You can do this by issuing:

which java

And with the results repeatedly issue

ls -l /path/returned/by/the/previous/command

In my case I ended up here:

/usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java

this will be my JAVA_HOME.

Glassfish preparations

open up /etc/bashrc as su:

su
gedit etc/bashrc

add this to the end of the file and save the file:

#GLASSFISH
export JAVA_HOME=/usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
export GLASSFISH_HOME=$ORACLE_BASE/product/3/glassfish
export PATH=$PATH:$JAVA_HOME/bin:$GLASSFISH_HOME/bin

Of course you need to change line 2 with what you found to be your JAVA_HOME, but I reckon that it’ll be the same as what I found.

Start SQL*plus. We need to shut down the EPG:

execute dbms_xdb.sethttpport(0)
exit

Exit the terminal to get your changes applied.

Install Glassfish

Open a terminal again

su
cd /u01/app/oracle/product/3/glassfish/
wget http://dlc.sun.com.edgesuite.net/glassfish/v3/release/glassfish-v3-unix.sh
sh ./glassfish-v3-unix.sh

This downloads the Glassfish 3 installer and executes it.

glassfisinst-01-welcome

Click “Next”

glassfishinst-02-license

Accept the terms.. “Next”

glassfishinst-03-installdir

specify the directory: /u01/app/oracle/product/3/glassfish.. “Next”

glassfishinst-04-adminsettings

We write down the values here for later reference:

  • 4848  admin port
  • 8080  http port
  • admin  username
  • secret  password

Click “Next”.

glassfishinst-05-updateconfig

Make the changes that apply for your network. I don’t have a proxy in mine. So “Next” suffices…

glassfishinst-06-JDKselection

I didn’t change anything here.. “Next”

glassfishinst-07-ready2install

Nothing to do here: “Install”

glassfishinst-08-installing

Now we wait…

glassfishinst-09-prodreg

I skipped this

glassfishinst-10-summary

“Exit”

Ready.. Now we must configure GlassFish.

In this post we’ll configure the GlassFish 3 server that we installed in the previous post.

Information has been aggregated from different blogs:

Apex & Apex listener download

Apex and the listener should be downloaded now.

Now we start the admin console and

mkdir -p $ORACLE_BASE/product/1.1.2/apxlistener
mkdir -p $ORACLE_BASE/product/4.0.2
unzip apex_listener.1.1.2.131.15.23.zip -d $ORACLE_BASE/product/1.1.2/apxlistener
unzip apex_4.0.2.zip -d $ORACLE_BASE/product/4.0.2

Running Glassfish as a service

A script must be created in /etc/init.d

gedit /etc/init.d/glassfish

Paste this into the new file:

#!/bin/bash
# description: Glassfish Start Stop Restart
# processname: glassfish
# chkconfig: 244 20 80
export JAVA_HOME=/usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
export PATH=$JAVA_HOME/bin:$PATH
export GLASSFISH_HOME=/u01/app/oracle/product/3/glassfish

case $1 in
start)
sh $GLASSFISH_HOME/bin/asadmin start-domain domain1
;;
stop)
sh $GLASSFISH_HOME/bin/asadmin stop-domain domain1
;;
restart)
sh $GLASSFISH_HOME/bin/asadmin stop-domain domain1
sh $GLASSFISH_HOME/bin/asadmin start-domain domain1
;;
esac
exit 0

Now, make the script executable and add it to our chkconfig so it starts at boot.

chmod 755 /etc/init.d/glassfish
chkconfig --add glassfish
chkconfig glassfish on
/etc/init.d/glassfish start

Copy Oracle Apex Images

Apex assumes the /i/ folder on the http server to contain the apex images. We copy the files like:

$GLASSFISH_HOME/bin/asadmin start-admin
cp -r $ORACLE_BASE/product/4.0.2/apex/images $GLASSFISH_HOME/glassfish/domains/domain1/docroot/i/

Glassfish configuration

Now we open the browser at this address: http://localhost:4848/.
The server will ask us to sign in. Use the username “admin” and the password you supplied when installing Glassfish.

  1. Go to “Configuration – Security” in the tree at your left hand.
  2. Check the checkbox at “Default Principal To Role Mapping”
  3. Click the “Save” button at the top of the screen.

Now we’re going to add some users:

  1. Expand the “Configuration – Security – Realms” node in the tree
  2. Select the “file” realm
  3. Click the “Manage Users” button
  4. Click “New..”
  5. Create
    1. User: “Aminlistener”
    2. Group List: “Admin”
    3. Password: “verysecret”
    4. Click “OK”
  6. Repeat step 5 for:
    1. User: “managerlistener”
    2. Group List: “Manager”
    3. Click “OK”

Install the apax.war listener:

  1. Click the “Applications”-node in the tree
  2. Click the “Deploy” button
  3. Select “Packaged File to Be Uploaded to the Server”
  4. Click the “Browse” button and navigate to:
    /u01/app/oracle/product/1.1.2/apxlistener/apex.war
  5. On the “Deploy Applications or Modules”  specify:
    1. Type: Web Application
    2. Content Root: apex
    3. Application Name: apex
    4. Status: Enabled (checkbox: on)
    5. Description: Application Express Listener
    6. Click “OK”

Configure the Listener

  1. Open a new browser (tab/window): http://localhost:8080/apex/listenerConfigure
  2. See the section on Configuring the apex listener

That’s it.

This is post 3 in my series about a fully freeware CentOS Apex environment

Configure the APEX Listener

Your listener is deployed, but not yet configured. Go to http://localhost:8080/apex/listenerConfigure

We must set parameters in three tabs:

  1. Connection
    • Username: apex_public_user
    • Password: the password as set earlier for this user
    • Connection Type: Basic
    • Hostname: localhost
    • Port: 1521
    • SID: XE
  2. Security
    • Database Validation Function: wwv_flow_epg_include_modules.authorize
  3. Caching
    • Procedure Names: wwv_flow_file*
    • Maximum entries: 500

listener_config_01 listener_config_02 listener_config_03

Click the “Apply” button after you made all changes. The page remembers the settings when you switch between tabs.

As you see I’m configuring from my Windows host towards the Linux guest (running VirtualBox).

Apex is now ready. Have a look at these links:

Creating a workspace:

You can create a workspace by going to : http://localhost:8080/apex

apex_internal_workspace_01

The ADMIN@INTERNAL password is the same as what you used for the SYS and SYSTEM “users” when installing Oracle XE.

That’s it.

This is part two of my series regarding a fully freeware APEX setup.

Post 1 coveres the installation of Oracle XE 11 beta on CentOS 5

Shut Down Apex-EPG

Log in as system into the XE database using SQL*plus. We must close the EPG within the database, because Tomcat is going to use the same port (8080)

execute dbms_xdb.sethttpport(0);

Tomcat installation

I took this from here.

su -
cd /etc/yum.repos.d
wget 'http://www.jpackage.org/jpackage50.repo' yum update
yum install tomcat6 tomcat6-webapps tomcat6-admin-webapps
service tomcat6 start

Tomcat is running!

tomcat_01

That was easy enough. We need to do some configuration.

If you get dependency errors please have a look at the original post essentially it says to try this:

rpm -Uvh http://plone.lucidsolutions.co.nz/linux/centos/images/jpackage-utils-compat-el5-0.0.1-1.noarch.rpm

and then try again.

Firewall configuration

setup
"Firewall configuration"
"Customize"
"Other ports" 8080:tcp
"Ok"
service tomcat6 restart

Downloads: APEX Listener and APEX itself

Even though XE 11g is shipped with Apex preconfigured, for this setup we do need to link to the images folder. We do this by downloading the full Apex archive. At the same time we can allready download the listener as well:

Unzip Apex:

unzip apex_4.0.2.zip
unzip apex_listener.1.1.2.131.15.23.zip -d apex_listener

We only need the images folder from the apex distribution. Nevertheless it can come in handy when the full apex installer is available.

The Tomcat htmlroot (or docroot) is located at /var/lib/tomcat6/webapps.

We copy the apex and the listener installer files into the Oracle tree and create a symbolic link in tomcats’ webapps folder:

su -
mkdir $ORACLE_BASE/product/4.0.2
cp -r apex $ORACLE_BASE/product/4.0.2/apex/
ln -s $ORACLE_BASE/product/4.0.2/apex/images /var/lib/tomcat6/webapps/i
mkdir $ORACLE_BASE/product/1.1.2
cp -r apex_listener $ORACLE_BASE/product/1.1.2/apex_listener

Tomcat configuration

Edit the /etc/tomcat6/tomcat-users.xml. We’re still root..

gedit /etc/tomcat6/tomcat-users.xml

replace the last line (having “</tomcat-users>”). Replace the username and password as desired.

  <role rolename="manager"/>
  <role rolename="admin"/>
  <role rolename="Manager"/>
  <role rolename="Admin"/>
  <user username="apex" password="verysecret" roles="manager,admin,Manager,Admin"/>
</tomcat-users>

It’s a bit silly that the roles are mentioned twice, but apparently not all implementations use the same casing.
I’m using the “apex” user here with the password “verysecret”

Save the file (Duhh 😉 )

Now we must make sure that Tomcat gets started at boot-time:

chkconfig --add tomcat6
chkconfig tomcat6 on
reboot

That should do the trick. So far for Tomcat for now.

Installing the APEX listener

First we need to unlock the “apex_public_user” and set its password. Open up the SQL*plus commandline and enter:

alter user apex_public_user account unlock;
alter user apex_public_user identified by the_secret_password;

Now open Tomcat manager: http://localhost:8080/manager/html. Go to the section: WAR file to deploy.

tomcat_manager_01

Click the browse button and select the warfile from /u01/app/oracle/product/1.1.2/apex_listener/apex.war

Click the “deploy” button.

Now you’re ready to configure the listener

<EDIT sept 2, 2011>

Today oracle released the definitive version of Oracle XE 11.2. I haven’t had the opportunity to test that version against my blogs, but I’ll do that shortly. stay tuned

</EDIT>

In my effort to create a fully free APEX environment this post is step 1: Install CentOS-5 and Oracle XE 11g.

This series will consist of a number of posts:

This is post 1, covering the basic installation.

Install CentOS-5

In my first attempts to get to this fulle freeware APEX environment I decided to use Ubuntu server with the GNOME desktop. However I found out that most software is delivered in RedHats RPM format. Especially the Oracle HTTP server preferes to be installed on a RedHat compliant system. CentOS is just that.

Just do a clean install CentOS downloaded from their site. I used version 5. But make sure you use the 64 bit version.

After the clean install I installed the VirtualBox extensions:

  1. Choose “Devices” – “Install Guest Additions”
  2. Open a terminal:
    su -
    cd /media/VBOXADDITIONS_4.0.6_71416/
    ./VBoxLinuxAdditions.run

    This installs the VBox additions. We do need a reboot:

    shutdown -r now

Install Oracle XE 11g beta

  1. Download the installer here.
  2. Open a terminal and go to the directory where you downloaded the ZIP
    mkdir OracleXE
    unzip linux.x64_11gR2_OracleXE.zip -d OracleXE
    su -
    cd /home/apex/Downloads/OracleXE
    rpm -ivh oracle-xe-11.2.0-0.5.x86_64.rpm
  3. We’re still Super so we can kick the configuration straight away:
    /etc/init.d/oracle-xe configure

    the installer will ask for a port to run Apex (8080), a port to run the database listener (1521) a password to be used for both SYS and SYSTEM users and whether you’d like to have the database start automatically at system start (y). As a famous dutch beer-commercial states: “now we wait”.

  4. When the installer finishes I put the apex user (the one I use to log in into the system) to the dba group. If we ommit this step we’ll not be able to use SQL*plus as the regular user (in my case this user is called “apex”).
    usermod -G dba apex
  5. Now we need to edit the bashrc file to have the paths and system variables set correctly for everyone on the system.
    gedit /etc/profile

    In the editor at the end of the file add these lines:

    #ORACLE XE 11g Beta
    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
  6. Now let’s reboot. We’re finished installing XE !
    shutdown -r now
  7. In the menu go to: Applications – Oracle Database 11g…. – Get Started
    This starts the browser and opens the APEX environment.When the page opens correctly we know that:

    1. The database starts automatically
    2. The EPG is running on port 8080

If you continue to use the EPG, you’re ready.

apex11g-01

if you want to use a different HTTP server you should continue:

You can also use the APEX listener in a stand-alone mode.