Friday, November 03, 2006

Java Process and Instance Data From OracleAS

In the Oracle Application Server it is standard practice to set up a cluster with multiple application server instances hosting multiple OC4J instances each run atop of multiple JVMs.

Frequently when executing a specific application instance (servlet/EJB/Web service), it can be useful to have the exact location you are running - which Application Server instance, which specific OC4J instance and sometimes even the exact JVM instance. Sometimes you need this for your application to make some application centric decision, but more often it is useful for debugging when working in large clusters.

This blog is inspired by Steve Button's work where he built a very cool utility for session tracking in a cluster which implicitly revealed this information - he needed it himself while building it to debug as well to show to the user.

So how do you determine this on Oracle Application Server? There are several system properties that will help you out, specifically:

  • oracle.home - the physical directory in which your application server is installed
  • oracle.oc4j.instancename - the name of your OC4J instance
  • oracle.ons.instancename - your OracleAS instance name
  • oracle.ons.indexid - a combination of your OC4J instance name, the group it belongs to and the actual JVM executing it (for example if there is > 1 JVM you have configured as per my previous post on this topic)
On my cluster - I have a lot of AS and OC4J instances running :-) ... but in the picture below you can see that for this sample, I have highlighted the pieces of interest. In particular, one of the Oracle Application Server instances is named is soa_javaee.MLEHMANN-LAP. In that instance I have several OC4J instances, one in particular called javaee_1 that is configured to run on top of 2 JVMs. That OC4J instance is grouped together with several others in a synchronized group called javaee_group. If you look to the bottom of the graphic below, you will see this:

To try out these properties, I deploy a servlet to that OC4J instance javaee_1 and within that servlet I have the following code:


Oracle home name: " + System.getProperty("oracle.home"));

OC4J Instance name: " + System.getProperty("oracle.oc4j.instancename"));

AS Instance name: " + System.getProperty("oracle.ons.instancename"));

Instance:Group:JVM PID: " + System.getProperty("oracle.ons.indexid"));

What it spits out the other side in my browser is:

Oracle home name: D:\oracle\product\soa_javaee
OC4J Instance name: javaee_1
AS Instance name: soa_javaee.MLEHMANN-LAP
Instance:Group:JVM PID: java_ee1.javaee_group.2

Pretty useful information ... try it out :-)

No comments: