How to use JConsole, JVisualVM or VisualVM with Oracle Application ServerThis is a featured page

You can use JConsole, JVisulaVM or VisualVM to monitor Oracle Application Server or OC4J standalone.

JConsole: Sun, http://java.sun.com/javase/6/docs/technotes/guides/management/jconsole.html
JVisulaVM: Sun, http://java.sun.com/javase/6/docs/technotes/tools/share/jvisualvm.html
VisualVM: https://visualvm.dev.java.net/

VisualVM has been available as a distinct open source product for some time, but has been included with Sun's JDK since Java SE 6 Update 7 as JVisualVM. It provides advantages of JConsole such as visualization of memory and performance data and generic access to JMX MBeans.

See also Metalink Note 443506.1.

  • Add "-Dcom.sun.management.jmxremote" to your JVM.

For Application Server 10.1.3.x goto $ORACLE_HOME/opmn/config.
Edit opmn.xml. Add this to the process-type/start-paramters/java-options of the "home" or "oc4j-soa" or ...
Restart Application Server

For OC4J standalone edit $ORACLE_HOME/bin/oc4j.cmd or oc4j.sh, add
set JVMARGS=%OC4J_JVM_ARGS% -Dcom.sun.management.jmxremote=true
or
set OC4J_JVM_ARGS=-Dcom.sun.management.jmxremote=true before starting OC4J

For Application Server 11g (Technology PreviewTP3, TP4 or TP5)
- Go to your $JDEV_USER_DIR/system11.1.1.0.22.48.95/o.j2ee/embedded-oc4j/bin
( for TP5 go to $JDEV_USER_DIR/system11.1.1.0.30.50.54/o.j2ee/embedded-oc4j/bin)
- Edit the startsoa(.bat): add "-Dcom.sun.management.jmxremote" to the JAVA_VM paramter
- Start the server with this script directly or from within the JDeveloper 11g.

  • Start JConsole and select the local process with "oc4j..."
JConsole Connection

JConsole screens:
JConsole Screen 1

JConsole Screen 2

  • Start JVisualVM/VisualVM and select on the left side the process with "oc4j.jar"
JVisualVM/VisualVM screen:
visualvm sreen

  • Tested also with JDK 1.6.0.10, see screen
VisualVM with OC4J and JDK6

  • If you want to connect to a remote OC4J you can do this by starting JConsole with the following parameter:
jconsole
-J-Dcom.sun.management.jmxremote.ssl=false
-J-Dcom.sun.management.jmxremote.authenticate=true
-J-Djmx.remote.protocol.provider.pkgs=oracle.oc4j.admin.jmx.remote
-J-Djava.class.path=;%JAVA_HOME%\lib\jconsole.jar;%JAVA_HOME%lib\tools.jar;%ORACLE_HOME%\j2ee\home\lib\adminclient.jar;%ORACLE_HOME%\j2ee\home\oc4jclient.jar

Using the advanced connection tab, you can specify the direct JMX Service URL to identify the target server.
To connect remotely to an OC4J process the URL is of the format

OC4J standalone:
service:jmx:rmi://[oc4j-host]:[oc4j-port]
e.g. service:jmx:rmi://localhost:23791, User Name: oc4jadmin, password: welcome1
Oracle Application Server(OPMN managed):
service:jmx:rmi:///opmn://<hostname>:<opmn-port>/<container-name>
e.g. service:jmx:rmi:///opmn://localhost:6005/home, User Name: oc4jadmin, password: welcome1

  • If you want to connect to a remote OC4J you can do this by starting JVisualVM or VisualVM with the following parameter:
jvisualvm
-J-Dcom.sun.management.jmxremote.ssl=false
-J-Dcom.sun.management.jmxremote.authenticate=true
-J-Djmx.remote.protocol.provider.pkgs=oracle.oc4j.admin.jmx.remote
--cp:a %ORACLE_HOME%\j2ee\home\lib\adminclient.jar;%ORACLE_HOME%\j2ee\home\oc4jclient.jar

Using File -> Add JMX Connection, and "Use security credential" (e.g. oc4jadmin/welcome1)

With the option "--cp:a" you define the classpath for the netbean. See "visualvm --help".
With the option "-J-Dnetbeans.logger.console=true" you can get the logging to the console.

Tested with JVisualVM: Java SE 6 Update 13 and 14 and VisualVM 1.1.1.




robert.baumgartner
robert.baumgartner
Latest page update: made by robert.baumgartner , Jun 20 2009, 3:00 AM EDT (about this update About This Update robert.baumgartner classpath for visualvm - robert.baumgartner

3 words added
3 words deleted

view changes

- complete history)
More Info: links to this page
Started By Thread Subject Replies Last Post
steffm "Attach Listener" - java.lang.reflect.InvocationTargetException 0 Sep 24 2009, 1:12 PM EDT by steffm
Thread started: Sep 24 2009, 1:12 PM EDT  Watch
Hi Robert

I'm Unable to use JVisualVM profiler with Standalone OC4J 10.1.3.4 (JDK 1.6) :

Exception in thread "Attach Listener" 09/09/11 16:58:15 java.lang.reflect.InvocationTargetException
09/09/11 16:58:15 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
09/09/11 16:58:15 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
09/09/11 16:58:15 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
09/09/11 16:58:15 at java.lang.reflect.Method.invoke(Method.java:597)
09/09/11 16:58:15 at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:323)
09/09/11 16:58:15 at sun.instrument.InstrumentationImpl.loadClassAndCallAgentmain(InstrumentationImpl.java:348)
09/09/11 16:58:15 Caused by: java.lang.NullPointerException
09/09/11 16:58:15 at org.netbeans.lib.profiler.server.ProfilerActivate15.getArchiveFile(ProfilerActivate15.java:75)
09/09/11 16:58:15 at org.netbeans.lib.profiler.server.ProfilerActivate15.activate(ProfilerActivate15.java:96)
09/09/11 16:58:15 at org.netbeans.lib.profiler.server.ProfilerActivate15.agentmain(ProfilerActivate15.java:61)
09/09/11 16:58:15 ... 6 more
Agent failed to start!

Steps to Reproduce Problem are :

1. Run the server using ==> java -Dcom.sun.management.jmxremote=true -jar oc4j.jar
2. Run JAVA_HOME/bin/jvisualvm. (detected by VisualVM)
3. Double click on OC4J node. I see a tab for PROFILER (along with Threads and memory)
4. Click on profiler TAB
5. When I click on MEMORY or CPU buttons, gives an empty box. An exception is displayed.

According to your doc, it should work.
Note also that the other TABS work fine, except for the "Profile" tab.

Thx for your hints.
Steff
Do you find this valuable?    
Showing 1 of 1 threads for this page