| Software Secret Weapons™ |
JMX In Apache Tomcat posted by Pavel Simakov on 2006-03-09 18:26:20 under Linguine Watch
|
||||
|
I have recently discovered that Tomcat 5.0.25 does not support JMX monitoring. This is sad news, which needed attention. Hereunder is a workaround to make Tomcat 5.0.25 JSR 160 compatible as told to me by a friend. JSR 160 provides a standard way to connect to remote JMX-enabled applications using RMI; it is possible to use JMX JSR 160 implementation on client side, and have a JMX Remote Reference Implementation on server side, or vice versa. This allows the creation of Management Consoles based on Swing, for example that will be able to interoperate no matter which JMX implementation is used.
To make a system (or system component) accessible for monitoring via JMX-enabled monitoring applications this system has to be JSR 160 compatible.
It can be achieved by running this system component on JDK1.5, or using third party implementation such as MX4J
The Problem
The Solution But you can change the jmx.jar library content. I took latest MX4J 3.0.1 and repacked compiled code from jars into one. Specifically I took the following jars from mx4j-3.0.1 distribution pack:
and put them into one jar - jmx.jar. That was it. Now while still running Tomcat 5.0 your web application can register MBeans and expose them through MX4J implementation of RMI Adapter for external management.
Comment (1) Leave a comment |
|
||||
| Copyright © 2004-2007 by Pavel Simakov |
|
Comment by Deepak — November 27, 2007 @ 8:40 pm
Hi,
I’m trying to access the tomcat’s Mbean from outside the tomcat environment, i.e trying to access the Mbean from standalone application.
I’ve added and enabled the jmx port by the following code in server.xml
<Connector port=”0″
handler.list=”mx”
mx.enabled=”true”
mx.httpHost=”localhost”
mx.httpPort=”5566″
protocol=”AJP/1.3″ />
And trying to access the Mbean in the standalone java application by like this,
JMXServiceURL url = new JMXServiceURL(”service:jmx:rmi:///jndi/rmi://localhost:5566/jmxrmi”);
Map map = new HashMap();
String[] credentials = new String[] { “admin” , “admin”};
map.put(”jmx.remote.credentials”, credentials);
JMXConnector conn = JMXConnectorFactory.connect(url,map);
But i’m getting error
java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.CommunicationException [Root exception is java.rmi.ConnectIOException: error during JRMP connection establishment; nested exception is:
java.net.SocketTimeoutException: Read timed out]
and also getting following error in tomcat console
Exception during http request
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:168)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:183)
at java.io.BufferedInputStream.read(BufferedInputStream.java:201)
at mx4j.tools.adaptor.http.HttpInputStream.readLine(HttpInputStream.java
:272)
at mx4j.tools.adaptor.http.HttpInputStream.readRequest(HttpInputStream.j
ava:194)
at mx4j.tools.adaptor.http.HttpAdaptor$HttpClient.run(HttpAdaptor.java:9
54)
I’ve placed all the jar files MX4j related in the lib folder.
Please tell me wha’t is the issue
Thanks and Regards,
Deepak.S