This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Java in General and the fly likes JMX connection refused Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "JMX connection refused" Watch "JMX connection refused" New topic
Author

JMX connection refused

Mehul Mistry
Ranch Hand

Joined: Feb 10, 2006
Posts: 43
Hello Hello

I am using MxBeans for a small uitiliy in my application and also have a small client program of my own which will connect to the jmx port of my applicaition and invoke the operation on the MxBean. This all was working fine. However I am facing one small issue now and need some help to fix it. (I am not a very n/w and RMI person).

With same client which was working all this time, I am now facing connection refused exception. I really don't understand why it is behaving like this now. Below is the exception excerpt....

------------------------------------------------------------------------------------------------------------------------
Exception in thread "main" java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: 127.0.0.2; nested exception is:
java.net.ConnectException: Connection refused]
at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:338)
at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:248)
at com.example.Client.main(Client.java:59)
Caused by: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: 127.0.0.2; nested exception is:
java.net.ConnectException: Connection refused]
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: 127.0.0.2; nested exception is:
java.net.ConnectException: Connection refused
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:601)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.j

--------------------------------------------------------------------------------------------------------------------

I am running the program on a linux m/c running OPEN Suse linux.

Need help, where do I need to find the problem.

Thanks
Mehul

Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14190
    
  20

127.0.0.2 is a very strange IP address. Where does that come from?

127.0.0.1 means localhost - the computer you're running the program on. Did you make a mistake and enter 127.0.0.2 somewhere, where you were supposed to enter 127.0.0.1?


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Mehul Mistry
Ranch Hand

Joined: Feb 10, 2006
Posts: 43
Yes... 127.0.0.2 is starnge and I am not specifying it anywhere. The URL that I use to connect is as below...

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

This is what is giving the exception.

Thanks
Mehul

Mehul Mistry
Ranch Hand

Joined: Feb 10, 2006
Posts: 43
I tried mentioning ip too the URL. But still getting connection reused. Tried below URLs

"service:jmx:rmi:///jndi/rmi://:127.0.0.1.9999/jmxrmi"
"service:jmx:rmi:///jndi/rmi://:localhost:9999/jmxrmi"

Thanks
Mehul
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Jesper de Jong wrote:127.0.0.2 is a very strange IP address. Where does that come from?

127.0.0.1 means localhost - the computer you're running the program on. Did you make a mistake and enter 127.0.0.2 somewhere, where you were supposed to enter 127.0.0.1?



.2 is also localhost, at least in some contexts (i.e., the handful where I've tried it). I had to use it one time when writing a proxy service for Windows RDP. The RDP client would connect to localhost, which would then proxy the connection to the RDP server on the actual host we wanted to control. But RPD doesn't let you connect to 127.0.0.1. Turns out .2 and .3 work also. I assume the entier 127.0.0.X subnet is localhost, but i didn't dig too deeply into the details.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JMX connection refused