0

I tried to enable JMX remoting on a Java app running on a server by adding the JVM args -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9001 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=xxx.xxx.xxx.xxx, but I was unable to connect to the application. Not knowing if the application was messing it up somehow, I wrote a simple test app:

public class Main {
    public static void main(String[] args) {
        while (true) {
            try {
                System.out.println("Sleeping for 5 seconds...");
                Thread.sleep(5000);
            }
           catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}

However, I could not connect to this application, either. iptables shows an open port on 9001, and netstat confirms that a connection was established, but Jconsole (and a simple Groovy script) fails due to timeout.

Because my troubleshooting has failed thus far, I've been looking into alternative ways of getting Jconsole to connect. Solutions include installing a new webserver and routing JMX through that, but that is probably not feasible for me. There is a webserver on the box but it is Hiawatha and I can't change that or install another one. What have I missed?

1
  • 1
    What is netstat -tln telling you, is the port open on the right interface?
    – eckes
    Oct 22, 2017 at 4:18

1 Answer 1

1

Try these steps to troubleshoot and report back:

  1. Can you use telnet xxx.xxx.xxx.xxx 9001 from where you run the jconsole. You should see:

    Connected to xxx.xxx.xxx.xxx Escape character is '^]'.

If you do see that then that means you have a TCP connection so firewalls are not the problem.

  1. Run the following command on the server and post the output:

    $ netstat -an | grep LISTEN | grep 9001 tcp6 0 0 :::9001 :::* LISTEN

Your class and your command line:

-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9001 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false Main

work ok for me, I can connect to jconsole.

  1. Can you check what version of Java the host you want to monitor is running? java -version

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .