本文出处:http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6209663
Bug ID: | 6209663 |
Votes | 7 |
Synopsis | jconsole won't connect to remote JVM on Linux |
Category | java:jconsole |
Reported Against | |
Release Fixed | |
State | 11-Closed, Not a Defect, bug |
Priority: | 3-Medium |
Related Bugs | |
Submit Date | 16-DEC-2004 |
Description | |
Work Around | |
Evaluation | |
I see a very similar effect. I have one machine running Debian amd64 sarge that I am unable to connect to - I can connect locally using local connection. I can even connect "remotely" on the same machine by using 127.0.0.1 or it's IP address. I just cannot connect remotely from another machine - I get the same "Connection Failed". A netstat shows an ESTABLISHed connection to the correct port, the connection will not go TIME_WAIT until I click cancel on the connection window (even though it says Connection failed). I've tried both Debian i386/amd64 and solaris 10 beta 72 jconsoles (amd64 1.6.0 build) without success. A i386 machine with the exact same java -D args will allow connections. Its very very strange.
java version:
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) 64-Bit Server VM (build 1.5.0-b64, mixed mode)
/usr/lib/j2sdk1.5-sun/bin/java -server -Djava.awt.headless=true -Xmx896m -XX:+PrintGCDetails -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8400 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.endorsed.dirs=/usr/share/tomcat5/common/endorsed -classpath /usr/lib/j2sdk1.5-sun/lib/tools.jar:/usr/lib/j2sdk1.5-sun/jre//lib/jcert.jar:/usr/lib/j2sdk1.5-sun/jre//lib/jnet.jar:/usr/lib/j2sdk1.5-sun/jre//lib/jsse.jar:/usr/share/tomcat5/bin/bootstrap.jar:/usr/share/tomcat5/bin/commons-logging-api.jar -Dcatalina.base=/var/lib/tomcat5 -Dcatalina.home=/usr/share/tomcat5 -Djava.io.tmpdir=/var/lib/tomcat5/temp org.apache.catalina.startup.Bootstrap -config /etc/tomcat5/server0.xml start
Submitted On 21-DEC-2004
bclbob
Futher investigation
Java code:
public class Sleep
{
public static void main( String[] args)
{
try
{
Thread.sleep(10000000);
}
catch (Exception e)
{
// eat
}
}
}
java cmd line:
java -Dcom.sun.management.jmxremote.port=8900 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false Sleep
still causes the same issue on the amd64 machine, but connects fine on i386.
amd64 java -version:
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) 64-Bit Server VM (build 1.5.0-b64, mixed mode)
i386 java -version:
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode)
Submitted On 29-DEC-2004
opty
Same problem here on Linux Mandrake 10.1 for x86-64 (Xeon EM64T here), when looking on jconsole localy the remote jconsole connection thread is at
java.net.SocketInputStream.socketRead0() for for few seconds before terminating, so the there have been a connection but something failed while communicating...
Submitted On 06-JAN-2005
bclbob
Still an issue on Linux amd64 with SR1
java -version
java version "1.5.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_01-b08, mixed mode)
Can't connect remotely from Windows or Linux or Solaris 10 b72.
Submitted On 14-JAN-2005
masterzen666
I confirm the problem:
client on debian/sarge i386
server on debian/sarge amd64 (EM64T)
Same VM running on client & server (except 64bit one for server):
java version "1.5.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_01-b08, mixed mode)
Analysis of a network trace seems to show that the remote part sends 127.0.0.1 as IP address.
Analysis of a network trace taken on 'lo' (on the client) shows that the jconsole tries to connect to a port that is not open on the client (because it is open on the server).
It might be related to the /etc/hosts file and the hostname to IP conversion...
I found the culprit and a workaround: my /etc/hosts was:
127.0.0.1 localhost localhost.localdomain server4
Changed that to
127.0.0.1 localhost localhost.localdomain
192.168.0.230 server4
fixed the problem....
Submitted On 19-JAN-2005
bclbob
Thanks masterzen666 - that worked for me! great work
Submitted On 21-JAN-2005
marcoesch
I dont think it is related to name resolution. I am experiencing the same problem. On the server I can see the socket going in to LISTEN mode on the specified port. When the client tries to connect I can see it going into ESTABLISHED with ip address from the client running jconsole ... but still get connection fialed on the client.
tcp 0 0 *:9930 *:* LISTEN
tcp 0 0 ::ffff:10.107.0.15:9930 ::ffff:10.107.0.25:1641 ESTABLISHED
Submitted On 04-FEB-2005
opty
The above evaluation trick for /etc/hosts works with a straight connection, but it won
Submitted On 14-FEB-2005
bjerkz
The "trick" with /etc/hosts solves it for me, too.
Thanks!
Submitted On 03-MAR-2005
opty
/etc/hosts doesn
Submitted On 03-MAR-2005
opty
/etc/hosts does not resolve when using NAT or SSH tunneling
Submitted On 03-MAR-2005
Caffeine0001
If you are behind a NAT or firewall and having problems, see the second reply of http://forum.java.sun.com/thread.jspa?threadID=289869&messageID=1242288 and http://java.sun.com/j2se/1.4/docs/guide/rmi/faq.html#nethostname. Please also add this to the JConsole FAQ.
Submitted On 15-FEB-2007
I am running Ubuntu Edgy and I definitely see this problem. I don't know whose fault it is, but it's definitely a bug. I have a pretty comprehensive writeup including a workaround here:
http://trac.marketcetera.org/trac.fcgi/wiki/Marketcetera/UbuntuJMX
Submitted On 19-FEB-2007
HolgerK
If have the same problem even with proper hostname setup.
JDK 1.5.0.11, Linux/i386, two machines.
I can connect to the remote port via "telnet server port", but jconsole reports "connection failed" when started on client (oder server).
BTW: jmxremote documentation is inconsistant:
1.) gui screwup: I found no place how users and roles relate. all documentation seems to use these terms als synonyms. the remote dialog in jconsole should read "rolename", not "username" in this case.
2.) typo: the commed in jmxremote.password reads monitorRole and measureRole.
Submitted On 29-MAR-2007
SheepShepherd
For my RedHat AS3 the trick with /etc/hosts was not enough until I changed my host name with "hostname -v <name_of_my_machine>" command (root privileges are required).
Submitted On 26-JUL-2007
mipito
I'm having the same problem on a linux box and the 'hostname' fix doesn't help. Issuing 'hostname -i" gives me the true ip.
I fire up the process to be monitored on the server, ssl & authentication disabled. On the client (a pc) i fire up jconsole and the connection is established as displayed by netstat, but for some reason it ends up in "connection failed".
What is jconsole trying to do at this point? I can connect fine to that port using telnet.
Submitted On 27-JUL-2007
mipito
Ok, the problem i was running into (see my previous comment) and is now resolved is that the jvm you're trying to connect to actually exposes *two* ports, the one specified via -Dcom.sun.management.jmxremote.port, and some other one. The 2nd one is random, but jconsole wants to connect to it, so if you have a firewall, and you've only opened up the above port, you're hosed. I don't know if it's possible to specify both ports on the cmd line, which is what you'd want to do if you have to poke holes in your firewall.
I believe there is a way to write code to get around this problem, but that's a pain, in particular when one is not in control of that code.
Submitted On 22-AUG-2008
r_d
adding -Djava.rmi.server.hostname=<host ip> should help resolve this problem.
PLEASE NOTE: JDK6 is formerly known as Project Mustang
原文链接: http://blog.csdn.net/cyq1984/article/details/5766946