1

I am trying to profile a Java Spring application with the Oracle Java Mission control. I have the JVM Connection configured as: localhost:7091 and I started the application with java -Dcom.sun.management.jmxremote.rmi.port=7091 -jar app.jar.

When I attempt to start the flight recorder I get an error message.

Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: localhost; nested exception is: 
    java.net.ConnectException: Connection refused: connect]
Could not connect to a JVM at service:jmx:rmi:///jndi/rmi://localhost:7091/jmxrmi. Make sure one is running and that you are using the correct protocol in the Service URL.

Does anyone know what could be the reason for that error?

achingfingers
  • 1,827
  • 5
  • 24
  • 48
  • I know this is old but for anyone reasearching this problem it can work if you change the hostname from localhost (127.0.0.1) to the external ip address (commonly 192.168.X.X). Also check firewalls (ufw) and routers if you access it from another host. – Peter Andersson May 19 '15 at 11:32

2 Answers2

2

You could try to use auto discovery. Then the connection will show up automatically in JMC

-Dcom.sun.management.jmxremote.autodiscovery=true

You can also name the connection so you can identify it easily.

-Dcom.sun.management.jdp.name=App

and disable security

-Dcom.sun.management.jmxremote.authenticate=false

-Dcom.sun.management.jmxremote.ssl=false

Kire Haglin
  • 6,569
  • 22
  • 27
1

I had this issue. I had installed JDK 10 on Windows Server 2016. With JMC and the JVM I wished to monitor on the same server.

When going live, we switched the IP from a temporary IP to a live IP. However, JMC resolved localhost to the original IP. Also when specifying the server's current IP, JMC resolved it to the original IP.

Adding -Djava.rmi.server.hostname=localhost to the Java process I wanted to monitor, resolved the issue.

However, I will would still be interested to know why JMC (or RMI) still resolves incorrectly.

lafual
  • 683
  • 1
  • 7
  • 23