Reputation: 267010
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
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
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
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
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
Reputation: 106
If you use '\' in your 'export' statement, remove those.
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