简体   繁体   中英

Java Mission Control: Flight Recorder throws: javax.naming.ServiceUnavailableException

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?

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM