Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

JMX connection refused

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Mehul Mistry
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic