Blankman
Blankman

Reputation: 267010

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

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?

Upvotes: 4

Views: 11281

Answers (5)

Autumn
Autumn

Reputation: 339

You can try adding the parameters that you have added in JAVA_OPTS to CATALINA_OPTS. It should work that way.
Also make sure u are making the settings with the same profile login from where you are running tomcat.

Upvotes: 0

Autumn
Autumn

Reputation: 339

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 !

Upvotes: 3

Aamir Yaseen
Aamir Yaseen

Reputation: 487

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.

Upvotes: 14

James
James

Reputation: 15475

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}"

Upvotes: 2

Seego
Seego

Reputation: 106

  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.

Upvotes: 1

Related Questions