Monday, December 15, 2008

oc4j classloading diagnostics using MBean

Class Loading can be tricky in a J2EE environment. The Oracle Application server documentation provides good explanation on how the classloading works. However, at times, it is easier to just test if the classloader can find a class without having to go through the hops to execute the class. Fortunately, oc4j offers a MBean that can be used for that purpose. Here is the detail step to test if a class can be found by the classloader.

1. Log in enterprise manager console.
2. Click on your OC4J container name on the main topology web site.
3. Click on the link "Administration".
4. Click on the "Go To Task" icon as follows.

JMX -> System MBean Browser

5. Expand the ClassLoading node in the navigation pane, then select the singleton MBean instance.
6. Click the Operations tab in the right-hand pane, then click the executeQuery operation.

Three versions of the executeQuery operation are exposed. Click the version that takes one parameter.

7. Enter in a value as follows under the "Parameters" heading -> LoaderTree
8. Click the Invoke button to call the operation.

This will display the class loading hirearchy.

To test if a given class can be found by the classloader, repeat steps 7 & 8 with the following command in the parameters tree

FindResource(packagename.classname)


There are other queries/commands that you can run on the MBean. For a complete list reffer to the oracle documentation here

No comments: