Java jconsole jmx connection failure

前端 未结 4 1627
深忆病人
深忆病人 2021-02-10 07:13

I\'m trying to connect jconsole to a jvm invoked by:

java \\
-Djava.util.logging.config.file=./logging.properties \\
-Dcom.sun.management.jmxremote.ssl=false \\
         


        
相关标签:
4条回答
  • 2021-02-10 07:41

    new and better solution than using a manually coded agent, is to use the new parameter which seems to be introduced in Java 7:

    -Dcom.sun.management.jmxremote.rmi.port=7091

    So in combination - same port can be used:

    -Dcom.sun.management.jmxremote.port=7091 -Dcom.sun.management.jmxremote.rmi.port=7091

    Solution found here: http://hirt.se/blog/?p=289

    0 讨论(0)
  • 2021-02-10 07:51

    make sure you run your application using below command,

    java -Dcom.sun.management.jmxremote.port=9595 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -jar <your jar file name>
    

    then open jconsole with admin privilege; you might be able to connect without any issue.

    if you want to run multiple jar files, make sure to use different ports; otherwise it will give error saying it's already bind by the JVM

    0 讨论(0)
  • 2021-02-10 07:56

    You can set the second port with parameter -"Dcom.sun.management.jmxremote.rmi.port" where port number can be same as that of first one . Even after setting this it will promt for insecure connection ... please allow insecure connection then only it will allow you to proceed further otherwise till then in log you will find error failed to connect: java.lang.SecurityException: Expecting a sun.rmi.server.UnicastRef2 remote reference in stub!

    Thanks

    0 讨论(0)
  • 2021-02-10 08:02

    The out-of-the-box JMX implementation uses two ports - one for the registry (the one that you specified) and one for the actual connection which is selected randomly (!). This is quite a design flaw since the random selection of the second port makes it very hard to configure a firewall.

    There are ways around it however - either you can do it yourself manually, or if you are using Tomcat you let it handle it for you.

    0 讨论(0)
提交回复
热议问题