IC5Notice: We have upgraded developerWorks Community to the latest version of IBM Connections. For more information, read our upgrade FAQ.
Topic
  • 1 reply
  • Latest Post - ‏2012-02-24T04:06:42Z by Shawn_Jiang
satyads
satyads
1 Post

Pinned topic unable to connect to jmx server

‏2012-02-02T14:01:56Z |
I am trying to connect to JMX server using java.
Bean settings in config.xml

<gbean name="RMIRegistry">
<attribute name="port">${NamingPort + PortOffset}</attribute>
</gbean>
<gbean name="NamingProperties">
<attribute name="namingProviderUrl">rmi://${ServerHostname}:${NamingPort + PortOffset}</attribute>
</gbean>
<gbean name="DefaultThreadPool">
<attribute name="keepAliveTime">30000</attribute>
<attribute name="minPoolSize">${MinThreadPoolSize}</attribute>
<attribute name="maxPoolSize">${MaxThreadPoolSize}</attribute>
</gbean>
</module>
<module name="org.apache.geronimo.framework/jee-specs/2.1.1/car"/>
<module name="org.apache.geronimo.framework/server-security-config/2.1.1/car"/>
<module name="org.apache.geronimo.framework/j2ee-security/2.1.1/car">
<gbean name="JMXService">
<attribute name="protocol">rmi</attribute>
<attribute name="host">${ServerHostname}</attribute>
<attribute name="port">${JMXPort + PortOffset}</attribute>
<attribute name="urlPath">/jndi/rmi://${ServerHostname}:${NamingPort + PortOffset}/JMXConnector</attribute>
</gbean>
</module>
I am able to do telnet to the Namingport used for RMIRegistry. Also i am able to do telnet for JMX port.

Namingport is 9005
portoffset is 0
JMXport is 9091

Whenever i try connecting using the below code, i am getting the exception pasted below the code.
But, the same url is working when i run the application in tomcat.The difference i am finding in WASCE compared to tomcat is the extra port(Naming port) which is used for RMI registry. I am not able to understand why i am facing this error.
I guess i have to do some settings properly.But, i am not sure where i can start my debugging for the same.

code
=====
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi:///serverIp:JMXport//jmxrmi");
JMXConnector jmxc = JMXConnectorFactory.connect(url, null);

Exception
=========
java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: 10.40.1.199; nested exception is:
java.net.ConnectException: Connection refused: connect]
at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:338)
at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:248)
at in.co.netsol.watchdog.module.trend.PerformanceCollectionPerComponentThread.main(PerformanceCollectionPerComponentThread.java:742)
Caused by: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: 10.40.1.199; nested exception is:
java.net.ConnectException: Connection refused: connect]
at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:101)
at com.sun.jndi.toolkit.url.GenericURLContext.lookup(GenericURLContext.java:185)
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)
... 2 more
Caused by: java.rmi.ConnectException: Connection refused to host: 10.40.1.199; nested exception is:
java.net.ConnectException: Connection refused: connect
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:601)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:198)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:322)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:97)
... 7 more
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:529)
at java.net.Socket.connect(Socket.java:478)
at java.net.Socket.<init>(Socket.java:375)
at java.net.Socket.<init>(Socket.java:189)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:128)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:595)
... 12 more
Updated on 2012-02-24T04:06:42Z at 2012-02-24T04:06:42Z by Shawn_Jiang
  • Shawn_Jiang
    Shawn_Jiang
    154 Posts

    Re: unable to connect to jmx server

    ‏2012-02-24T04:06:42Z  
    Have you every tried to run the jmx client code in the same machine the server is running on ? Then you can put localhost to the jmx url to see if the service is not listening to your external IP.

    Another way to look at if the correct port have been setup is to use:

    netstat -na

    to find out the listening port/host.