Saturday, March 27, 2010

How to connect JConsole to WAS 7

It's a bit tricky, but it's perfectly possible to connect (Sun's) JConsole to a remote WAS7 instance without any special server setup. You will only need to add a couple of JARs from the WAS runtime to JConsole's classpath. Also, the JMX URL to use is a bit special. Here is a Batch script for Windows that you can use as a starting point:

set JAVA_HOME=c:\Program Files\java\jdk1.6.0_17
set WAS_HOME=c:\IBM\WebSphere\AppServer
set CP=%JAVA_HOME%\lib\jconsole.jar
set CP=%CP%;%WAS_HOME%\runtimes\com.ibm.ws.admin.client_7.0.0.jar
set CP=%CP%;%WAS_HOME%\runtimes\com.ibm.ws.ejb.thinclient_7.0.0.jar
set CP=%CP%;%WAS_HOME%\runtimes\com.ibm.ws.orb_7.0.0.jar
set HOST=localhost
set PORT=9100
"%JAVA_HOME%\bin\jconsole" -J-Djava.class.path="%CP%" ^
service:jmx:iiop://%HOST%:%PORT%/jndi/JMXConnector

PORT must be set to the ORB_LISTENER_ADDRESS in the WebSphere configuration.

6 comments:

  1. Hello
    I connected to the distant server well only the window of consultation of the "MBeanses" is on the other hand active I want to consult the other parameters as the JVM, Threads, the classes charged in memorial,
    I don't know how to parameterize them

    Thank you

    ReplyDelete
  2. The first 5 tabs in JConsole visualize information gathered from a couple of standard MBeans called "platform MXBeans". They are registered automatically in the platform MBean server (the one managed by the JRE), but not in WebSphere's MBean server. I have some code that cross-registers these MBeans in WebSphere's MBean server, but since I developed this at work, it's not Open Source.

    ReplyDelete
  3. Hello,


    I am trying to access the remote WAS7 server Mbenas through my local machines with SUN JDK,

    Iam getting ther following error message.

    May 20, 2011 10:37:03 AM com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl
    WARNING: "IOP00410201: (COMM_FAILURE) Connection failure: socketType: IIOP_CLEAR_TEXT; hostname: apacsgdsiw0380.apac.nsroot.net; port: 2809"
    org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 201 completed: No
    at com.sun.corba.se.impl.logging.ORBUtilSystemException.connectFailure(ORBUtilSystemException.java:2200)
    at com.sun.corba.se.impl.logging.ORBUtilSystemException.connectFailure(ORBUtilSystemException.java:2221)
    at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.(SocketOrChannelConnectionImpl.java:205)
    at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.(SocketOrChannelConnectionImpl.java:218)
    at com.sun.corba.se.impl.transport.SocketOrChannelContactInfoImpl.createConnection(SocketOrChannelContactInfoImpl.java:101)
    at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.beginRequest(CorbaClientRequestDispatcherImpl.java:152)
    at com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.request(CorbaClientDelegateImpl.java:118)
    at com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.is_a(CorbaClientDelegateImpl.java:211)
    at org.omg.CORBA.portable.ObjectImpl._is_a(ObjectImpl.java:112)
    at com.ibm.WsnBootstrap.WsnNameServiceHelper.narrow(WsnNameServiceHelper.java:61)
    at com.ibm.ws.naming.util.WsnInitCtxFactory.getWsnNameService(WsnInitCtxFactory.java:1398)
    at com.ibm.ws.naming.util.WsnInitCtxFactory.getRootContextFromServer(WsnInitCtxFactory.java:949)
    at com.ibm.ws.naming.util.WsnInitCtxFactory.getRootJndiContext(WsnInitCtxFactory.java:866)
    at com.ibm.ws.naming.util.WsnInitCtxFactory.getInitialContextInternal(WsnInitCtxFactory.java:546)
    at com.ibm.ws.naming.util.WsnInitCtx.getContext(WsnInitCtx.java:123)
    at com.ibm.ws.naming.util.WsnInitCtx.getContextIfNull(WsnInitCtx.java:798)
    at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:164)
    at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:179)
    at javax.naming.InitialContext.lookup(InitialContext.java:392)
    at javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(RMIConnector.java:1886)
    at javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1856)
    at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:257)
    at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:248)
    at sun.tools.jconsole.ProxyClient.tryConnect(ProxyClient.java:350)
    at sun.tools.jconsole.ProxyClient.connect(ProxyClient.java:296)
    at sun.tools.jconsole.VMPanel$2.run(VMPanel.java:280)
    Caused by: java.net.ConnectException: Connection refused: connect
    at sun.nio.ch.Net.connect(Native Method)
    at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:507)
    at java.nio.channels.SocketChannel.open(SocketChannel.java:146)
    at com.sun.corba.se.impl.transport.DefaultSocketFactoryImpl.createSocket(DefaultSocketFactoryImpl.java:60)
    at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.(SocketOrChannelConnectionImpl.java:188)

    Please assist me.
    I have set all claspath varibales.


    Thanks & REgards
    BHaskar

    ReplyDelete
  4. It says "java.net.ConnectException: Connection refused: connect", which indicates that apacsgdsiw0380.apac.nsroot.net:2809 is unreachable.

    ReplyDelete
  5. Hi Andreas:
    Thanks for this post as it's a great tip.
    I successfuly connect with JConsole to my WAS server instance, but my application MBeans are not shown.
    If I start JConsole standalone it shows the local java processes; I select the WAS server one and it connects and my application MBeans are visible.
    Did you face this situation before?

    Thanks.

    ReplyDelete
  6. WebSphere creates its own MBean server (in addition to the platform MBean server created by the JRE on demand). If you don't see your custom MBeans, then this means that they are registered in the platform MBean server, not the MBean server used by WebSphere.

    ReplyDelete