My Oracle and Solaris Experience Overview

This post is to be updated as I dig out more of my original notes and bookmarks. It was written for an overview document to be handed to the next person handling the Oracle project:

The Oracle ADF development guide gives a good overview of the entire Application Development Framework as provided by Oracle and is targeted at Oracle 10g. There is a short presentation on ADF available.
Migration to Oracle from Access is best done using the ODBC connection to Oracle and standard SQL commands. There are other alternatives but most migration tools didn’t work properly or were expensive. Some of the tools tried include Oracle SQL Developer, EMS Data import, Apatar, Oracle Migration Workbench (see this forum thread).

The installation process of Oracle on Solaris took some time to get to work but despite a few typos this guide is the best source of information on Oracle installation. More information is available here but this is a slightly different installation method. My blog at has some of the steps I took to install Oracle as well as a few of the pitfalls in the documentation to watch out for.
There is some slightly outdated info on Oracle’s built in http server here and here which helped explain a few of the different components Oracle needs for http.

The Oracle web server of choice is OC4J, Oracle Containers for Java. The most useful tutorials for working with JDeveloper and OC4J were on deployment of applications as well as this, the most important tutorial in this list on JSF, EJB and Oracle’s preferred way of writing web apps with JDeveloper. OC4J is based on Apache and must be installed separately to Oracle. A cut down old version of OC4J is included with Oracle 10g but this is not to be used to develop apps. A lot of the documentation is confusing on this but after checking the forums it appears you need to install a standalone OC4J instance or install the Oracle Application Server. I installed the standalone OC4J as it seems much easier to use and the documentation I found is mainly focused on the standalone version.

I had a look at Oracle htmlDB, which has been updated and is now called Apex (Oracle Application Express). This is supposed to be a very quick way of prototyping database driven applications, see this unofficial overview. There is an unofficial wiki for Apex. I got Apex to work but the amount of flexibility provided was not enough and I was concerned that we would outgrow the abilities of Apex when writing custom apps.

The best way to write online apps looks to be the ADF way of doing things with Jdeveloper, Oracle 10g (or 11) and OC4J. For this you need to know Enterprise Java Beans, Java Server Faces and how to use Jdeveloper to deploy your applications to OC4J. I had problems deploying applications to my Solaris install of OC4J using Jdeveloper but have tested several small apps based on the tutorial (in bold above) using the built in OC4J server in Jdeveloper. My forum posts with the problems I faced following the deployment tutorial are here and here but I still didn’t manage to solve the problem. There is a third party forum devoted to developing for Oracle.

The key to Jdeveloper web application creation is Master-Detail relationships, made possible through foreign key relationships in the Oracle database and automatic object creation using Java Beans. Master-Detail relationships can be easily visualised using the templates available in Oracle ADF Server Faces (a more Oracle focused version of Java Server Faces) and there are plenty of tutorials available from Oracle like those in the official documentation.

Running Web Applications on Oracle OC4J and Solaris

I reached the stage where I can deploy the example web application from Oracle on my own standalone Oracle Containers for Java EE (OC4J) installation running on Solaris. There were a couple of hurdles before I got this far, one of which is a known bug with the Oracle Application Development Framework (ADF). Now that my Solaris install is set up I should be able to deploy applications written on my local machine (a Windows XP install) to my OC4J server using Oracle Jdeveloper.

First up I downloaded the latest version of the OC4J standalone install and extracted it to “/export/home/OC4J”. I set the “J2EE_HOME” environment variable to “/export/home/OC4J/j2ee/home” and made sure “JAVA_HOME” was set to “/usr/java”.

Next I tested the install by downloading the “Hello World” .jsp page from Oracle. After making sure this was working ok by placing it in “/export/home/OC4J/j2ee/home/default-web-app” and going to “http://serveraddress:8888/helloworld.jsp” I was ready to try installing an actual web application.

I followed the instructions from Oracle for deploying a web application. In short this requires you to enable the “oe” user in Oracle, set up a connection to your Oracle database and OC4J server in Oracle Jdeveloper and set up deployment projects for the example web application. This is all covered in the tutorial.

I tested the application on my local machine where it worked fine so I thought it could easily be deployed. I clicked “Deploy to OC4J” on the “OrderEntryApplication.deploy” .EAR file and the deployment failed. I tried using the web interface at “http://serveraddress:8888/em” to deploy the .EAR file manually and got the same error (sorry I didn’t record exactly what it was).

Next up I googled and found that you need the Oracle ADF installed on your OC4J server in order to run web applications. It isn’t installed by default in the OC4J standalone install so you need to install it manually. I read a few forum posts that said you could install ADF by just copying some .jar files across to your OC4J install but decided to do it the “proper” way as suggested by Oracle. I installed Jdeveloper on my Solaris box by downloading it and extracting to “/export/home/jdevstudiobase10134″ then started it by running “/export/home/jdevstudiobase10134/jdev/bin”. I shut down my OC4J server first as required and clicked “tools -> ADF Runtime Installer -> Standalone OC4J…” in Jdeveloper and went through the wizard to install the ADF runtime components.

This should have been fine but when I went to start the OC4J server up again I got an error:

Error initializing server: Shared library “” could not be found.

According to this forum post this is a bug and the workaround has even been included in the 10.1.3.x release notes addendum. To fix it you need to go into your “J2EE_HOME/config/server.xml” and remove the two references to the offending library by deleting this line twice:

<import-shared-library name=””/>

Now when you start up the OC4J server again it will start and you can visit your web application. One final thing, if following the tutorial make sure you visit “http://servername:8888/OrderEntry/faces/index.jsp”. I missed out the “/faces/index.jsp”, if you miss out the “faces” you get a server 500 error (the server doesnt know to use Java Server Faces) and if you miss out the “index.jsp” the link on the first page doesnt go anywhere!

Next step is to write a custom application to display, edit and add data in an Oracle database schema. I will be using Enterprise Java Beans for data objects and Java Server Faces for the front end on top of JSP. Still a fair way to go but at least now we can create and deploy applications using Oracle Jdeveloper.

Don’t Use OC4J Bundled with Oracle 10g

I couldn’t believe it when I saw it on this random forum post at Oracle’s own website but apparently you are not supposed to use the OC4J install that comes with Oracle for your own applications. It is meant only for internal settings!?

Please do not use the internal OC4J from the DB for your application. Please install a standalone OC4J instance which is available from OTN. You will not have the same functionality as you will with the standalone OC4J. That instance is used for internal settings (it is also used for the console), therefore please download an installation.

Is this why my “helloworld.jsp” page from Oracle themselves throws this error when placed in the default web app directory?

500 Internal Server Error

Servlet error: java.lang.ClassNotFoundException: _helloworld

I can only hope so. Next step, try installing a standalone version of OC4J and test using the same “helloworld.jsp” file. Why is this not CLEARLY stated in the documentation? The OC4J default install with Oracle includes a help file “OC4Jstandaloneguide.pdf” that doesn’t mention this anywhere! This could also explain why all the help I can find online references a default port of 8888 not the 1158 port that the Oracle Enterprise Manager is located on at “http://hostname:1158/em”.


I installed the OC4J standalone from Oracle available here by unzipping the downloaded file and setting the J2EE_HOME to the location of “<oc4j install dir>/j2ee/home”. It works, but it seems to really really slow down my machine after it is started. I need to look into this but at least I can view the test pages and my “helloworld.jsp” file works perfectly.

Using Webmin to Start Oracle Automatically on Solaris Boot

I tried a few different techniques to get my Oracle startup script to run at boot on Solaris. I couldn’t get it to work using the old style “init.d” and “rc_3.d” directory methods, which have now been depreciated in Solaris 10 and replaced with the “Service Management Facility (SMF)”. You can still use the old legacy methods but I just could not get them to work. I started to read up on the SMF and other methods for controlling bootup and found this page on informIT which is a chapter from a Solaris exam prep book. This chapter goes into a lot of detail and includes info on using the SMF as well as info on legacy service starting methods.

I was about halfway through this when it was suggested I use Webmin for Solaris to manage startup services etc. I hadn’t used webmin properly before but I was pretty amazed at how easy it makes quite a lot of system management.

My database startup script had to be started as the correct user (oracle) which I think was throwing off my previous attempts at starting the script as a service. I am positive there is a better way of running the script than using “su – oracle -c” then the command but I couldn’t find how else to make sure it was running as the right user..

Solution: Use Webmin to make a bootup action and let it take care of where the script is started from. I should really dig around and see exactly what it has changed but for the time being this will do fine.

  1. Install the Webmin package using the instructions on their site.
  2. Go to the Webmin page at “http://yoursite:10000″.
  3. Click “System” then “Bootup and Shutdown” then on the page that opens click “Create a new bootup and shutdown action”.
  4. Put in a name (has to be standard name, no spaces) and description of your script.
  5. Now put in the actual script in the “bootup commands” box. For me this was “su – oracle -c /export/home/app/oracle/oracle/product/10.2.0/db_1/startupdb”.
  6. Make sure it is set to start at boot time and click “Create”.


Now your script will start as a service at boot time. For me it made the boot a little longer than usual but it’s a price I’m willing to pay to not have to log in and start Oracle manually!

For reference my “startupdb” script is the following (which also includes environment variables I thought I might need):




sqlplus sys/password as sysdba <<ENDOFSQL
emctl stop dbconsole; emctl start dbconsole; lsnrctl start;

SQLPlus, SQL, Starting & Controlling Oracle Using Shell Scripts

I found a post by dbamac that describes how to run SQLPlus commands and SQL commands themselves from a shell script. I now use a script to start up my Oracle database and bypass my growing frustration with “dbstart” which seems to partially work now that I have set up the correct permissions on the startup.log and shutdown.log files.

As I have said before the way I boot oracle up is by running “sqlplus sys/password as sysdba” then typing “startup” and finally “exit” when it is all booted. I then run a nice long command “emctl stop dbconsole; emctl start dbconsole; lsnrctl start;” to restart the database web console and start the listener service up.

Thanks to dbamac I have now created a short script that does this in one go:

sqlplus sys/password as sysdba <<ENDOFSQL
emctl stop dbconsole; emctl start dbconsole; lsnrctl start;

I have to run the script as “oracle” as this is my user created during installation of the Oracle database who has all the right permissions etc. I stored the script as “startupdb” in my $ORACLE_HOME directory, in my case:

$ORACLE_HOME = /export/home/app/oracle/oracle/product/10.2.0/db_1/

So the command I use when I am logged in as root to start everything up is:

su – oracle -c $ORACLE_HOME/startupdb

The power of calling SQLPlus commands from the shell is awesome. It means you can set up cron jobs to automatically email reports, automatically backup data etc etc. Now I just need to get the script to start at boot, which means I am currently digging through the Solaris boot process using websites like this one from Admin’s Choice.

The final goal is to have Oracle automatically start when Solaris boots and then email me to tell me everything is up and running ok. I need to figure out a few things before but it would be an incredibly handy feature to have.


See this post for how I got Oracle to automatically start on Solaris boot.

Setting Up & Starting Apache and Tomcat on Solaris 10 x86

Apache, Java and Tomcat are all installed by default in my copy of Solaris 10 x86, I assume this is the same for all versions of Solaris. I was dreading compiling Apache and Tomcat from source and was even considering installing the package from Luckily I googled a bit more and soon realised everything was installed by default, which is actually a bit obvious when you think about it.

Thanks to a random bug report page on requesting an addition in documentation I got straight to the answer. I had to add an extra step in to add the required environment variables (which are now sitting in my “profile” file to be loaded each time). I’ve compressed the information a bit here but these are the steps I took to start Apache and Tomcat:

First add the two environment variables JAVA_HOME and CATALINA_BASE (for Tomcat) to your “/etc/profile” file or current session using usual “export” command:

export JAVA_HOME=/usr/java


export CATALINA_BASE=/var/apache/tomcat

Now you need to make sure the config files for both Apache and Tomcat exist with the right filenames. Luckily there are example config files included with both so you can just rename/copy these config files:

cp /etc/apache2/httpd.conf-example /etc/apache2/httpd.conf

cp /var/apache/tomcat/conf/server.xml-example /var/apache/tomcat/conf/server.xml

Now you can start up Apache:

svcadm enable apache

Now make a symbolic link to point the Tomcat “conf” directory to the Apache Tomcat “conf” directory (just to make sure config files come from the right place):

cd /usr/apache/tomcat

ln -s /var/apache/tomcat/conf conf

Now last of all, start up the Tomcat server using the script in the Tomcat “bin” directory:


Now you have both Apache and Tomcat running (on ports 80 and 8080 respectively). The home directory for Apache, where the html documents etc are stored, is located at “/var/apache2/htdocs/”. The home directory for Tomcat is at “/var/apache/tomcat/webapps/ROOT”.

Interestingly the test page for Tomcat at “http://localhost:8080″ states the environment variable as “$CATALINA_HOME” and not “$CATALINA_BASE” as I used. My Tomcat seems to be perfectly happy and I can run the sample applications so I guess you don’t need to worry about this.


If you have installed Oracle you can use Oracle’s own web application server (OC4J) at “http://localhost:1158″. There is a default page here with links to documentation etc. I’ll write more on using this once I figure out how to do dev work in Windows and push it to our Solaris installs.

Find Running CPU Intensive Processes in Solaris

After a quick googling I found this article at Sun on finding out what’s going on with your processes from a terminal. Just type:


into a terminal and get a great regularly refreshing task list. There are other commands to do similar things & prstat can do a lot more I’m sure but this is dead handy.

Turns out that Java (probably the Java desktop environment) chews a fair amount of cpu just sitting there not doing anything, its almost always at the top of the list for cpu percentage. It could be because I am using RDP to remote in via Remote Desktop but still, it’s not great.

Starting Local Oracle & Enterprise Manager on Solaris

I couldn’t figure out why my Oracle wasn’t auto starting when I rebooted Solaris. I tried the “dbstart” script but kept getting permissions errors no matter who I logged in as (probably my fault for setting ownership wrong somewhere). The solution was a bit basic but will do for now until we get auto starting working;

Log on as “oracle”, the user created during the pre-installation of Oracle 10g if you followed the installation documents. Open a terminal and start SQL*Plus from the Oracle “bin” directory by running:

sqlplus /nolog

If you are like me and hate unnecessary typing you added this bin directory to the “$PATH” environment variable. The “/nolog” means you can enter your connection info after SQL plus starts running, something I found I had to do in order to get it to connect to my local machine but not for remote machines.

Now you have a “SQL>” prompt connect as the “sys” account by typing in:

connect sys/password as sysdba

Now if you connected successfully you get a prompt back that says “Connected to an idle instance.” Next up type:


And that’s it, after a while it should start up your Oracle database and finally say “Database opened.” which means the database is now up and running and can be connected to remotely.

Now the Enterprise Manager Database Control (web interface) might have started up correctly when you started the database but for me it just didn’t. To get the status of the Enterprise Manager you open a terminal and type:

emctl status dbconsole

And more than likely it will tell you it is already running. I found out it wasn’t running by trying to start it, where it told me everything was fine and already started but I couldn’t reach the web page. Solution: turn it off and on again, if only everything worked like that.

emctl stop dbconsole

emctl start dbconsole

This fixed it for me, but now I have to figure out why Oracle is reporting it running at startup without it actually running. If the listener service isn’t running you will need to start this as well:

lsnrctl start


I tend to do everything in just 3 steps now, just to make things faster:

sqlplus sys/password as sysdba


then “exit” to quit out of sqlplus then the following line:

emctl stop dbconsole; emctl start dbconsole; lsnrctl start

TMP TMPDIR Temp Directories and Solaris Not Starting

If you set the TMP and TMPDIR environment variables in /etc/profile to a directory that does not exist Solaris will NOT load the desktop environment and you will not be able to log in. There is no error or warning, you just get booted back to the login screen.

Spotted this in an Oracle install when I was testing all the environment variables before actually creating the directories. The oracle directory I set in ORACLE_BASE does not need to actually exist when you log in as it is not used by Solaris itself but the TMP/TMPDIR directory does.

At some point I will write a step by step guide to installing Oracle 10g on Solaris x86 inside VirtualBox, at least then I will have something to follow myself without making mistakes like this!

Mounting .iso in Solaris

I found a pretty useful tip at with the following instructions to mount an .iso:

Given an ISO image in /export/temp/software.iso, a loopback file device (/dev/lofi/1) is created with the following command:

lofiadm -a /export/temp/software.iso /dev/lofi/1

The lofi device creates a block device version of a file. This block device can be mounted to /mnt with the following command:

mount -F hsfs -o ro /dev/lofi/1 /mnt