Can't connect jconsole to remote server, tomcat failing to start

10,939

Solution 1

You have to add the same host name in /etc/hosts file as you have defined in /etc/sysconfig/network file. This is how I solved my problem.

Solution 2

I have found the solution for this issue. Add the following in your catalina.sh file:

JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.port=7010 -Djava.rmi.server.hostname=${IP}"

Also add the following line in your /etc/init.d/hosts file:

127.0.0.1 localhost <your_hostname>

This resolved the issue. I am able to run jconsole as well as jvisualvm on this port now.
I hope this helps !

Solution 3

If you want to get the IP address dynamically you can try:

IP=`ifconfig  | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'`
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.ssl=false  -Dcom.sun.management.jmxremote.authenticate=false -Djava.rmi.server.hostname=${IP}"

Solution 4

  1. If you use '\' in your 'export' statement, remove those.

  2. To connect to remote java process, Use IP address of the server where your java process (tomcat instance) is running. The UnknownHostException is thrown when IP address could not be determined, so another option is to add the name - IP address definition to your hosts file.

Share:
10,939
Blankman
Author by

Blankman

... .. . blank

Updated on June 27, 2022

Comments

  • Blankman
    Blankman almost 2 years

    Trying to connect jconsole to a remote server.

    I added this to my catalina.sh:

    export JAVA_OPTS="-Dcom.sun.management.jmxremote \
        -Dcom.sun.management.jmxremote.port=9005 \
        -Dcom.sun.management.jmxremote.ssl=false \
        -Dcom.sun.management.jmxremote.authenticate=false \
        -Djava.rmi.server.hostname=xx.xx.xx.xx"
    

    catalina.out shows:

    Error: Exception thrown by the agent : java.net.MalformedURLException: Local host name unknown: java.net.UnknownHostException: myhostname: myhostname
    

    Not sure why it repeats my hostname in the error message?

    BTW, since I set authentication to false, in the jconsole app, do I leave username/password blank or is that for logging into the server?

    • Santosh
      Santosh over 12 years
      Are you using the property rmi.server.hostname for some other pupose (other than enabling JMX) ?
    • Blankman
      Blankman over 12 years
      I'm using it b/c I think you need it to connect to a remote server.
    • Aamir Yaseen
      Aamir Yaseen over 10 years
      Hi @Blankman, If you think my answer has solved your problem, can you please accept my answer? otherwise I'm happy to help you if you need any further assistance.