问题
According to this documentation http://tomcat.apache.org/tomcat-5.5-doc/monitoring.html#Enabling_JMX_Remote it should be possible to remotely Monitor a Tomcat 5.5 Server running on a JDK 1.4 but after searching all over the web and trying multiple OSs I still am no further than on day one. My results thus far are. Settign up Tomcat with the standard
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=%my.jmx.port%
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
-Djava.rmi.server.hostname=localhost
will work without any problems on JDK 1.5 and up. Debugging into Tomcat gives me access to the MBeanServer but I am not able to connect to it from the outside. According to the info from Wikipedia http://en.wikipedia.org/wiki/Java_Management_Extensions I just need a working connector and I have no idea how to get that working.
Trying to set up the HTTP Adaptor according to
<Connector port="${AJP.PORT}"
handler.list="mx"
mx.enabled="true"
mx.httpHost="${JMX.HOST}"
mx.httpPort="${JMX.PORT}"
protocol="AJP/1.3" />
has no effect at all. When I debugged it almost seemed like the attributes handler.list and mx.* were just ignored. I know I should just use JDK 1.5 and my worries would be gone but we have a large legacy install base of JDK 1.4 and it would be great if we could use the JMX monitoring. Eventually I want to use either JConsole or JVisualVM to connect to the Tomcat and as far as I have understood the connection URL would look like
service:jmx:rmi:///jndi/rmi://localhost:8888/jmxrmi
were 8888 is my JMX port. If anyone has some advice or ideas on how to drill to the root of the problem that would be very helpfull.
回答1:
JMX support had been added to Java since 1.5 (JDK5). To use it with JDK 1.4, an extension have to be dowloaded and installed http://java.sun.com/javase/technologies/core/mntr-mgmt/javamanagement/download.jsp . I did'n used it but that could be a starting point (from http://java.sun.com/developer/technicalArticles/J2SE/jmx.html )
JMX Technology Implementations
The Java 2 Platform, Standard Edition 5.0 (J2SE 5.0) supports JMX 1.2 and JMX Remote API 1.0, which is now the official JMX reference implementation (RI). For developers who are running J2SE 1.4, a JMX RI is also available from Sun Microsystems, and can be downloaded free of charge.
To connect from the outside, try to remove the line
-Djava.rmi.server.hostname=localhost
If your are using Linux, do like @vinothkr said for localhost resolving issue on JMX remote connection (file /etc/hosts, replace 127.0.0.1 with the server IP on the line where the hostname of the server appear). For Windows, I think the same thing could applied.
About the connector, it's the connector on your jmx remote port on the documentation you read. The connector you had setup on server.xml on protocol AJP/1.3 is not related. It concern communication between Apache HTTPd (or other Web Server / Load Balancer) and Tomcat.
回答2:
If you were able to connect to JVM running on Windows machines. Then the problem is your hosts.conf
Try hostname -i if it reports 127.0.0.1 then there is a problem
Check this FAQ no 5. http://download.oracle.com/javase/1.5.0/docs/guide/management/faq.html
As JMX uses port redirection. This causes problem
回答3:
do you have the remote server defined?
-Djava.rmi.server.hostname=localhost"
来源:https://stackoverflow.com/questions/3462354/tomcat-5-5-monitoring-with-jdk-1-4-on-windows