PDA

View Full Version : Catalina domain not visible when Tomcat JMX access is protected


alexk
25-06-2009, 02:44
I am trying to access tomcat (5.5) managed JMX MBeans, using the 2-port RMI connector workaround as described in http://tomcat.apache.org/tomcat-5.5-doc/monitoring.html

The environment is Win XP, Java 6 for both client and server.

When tomcat is started w/o JMX client authentication (-Dcom.sun.management.jmxremote), everything is fine.

With authentication (-Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.password.file=...jmx remote.password -Dcom.sun.management.jmxremote.access.file=...jmxre mote.access), I can get a connection fine (whenever the credentials are correct), but there is no "Users" or "Catalina" domains on the other end!

I thought it was an issue with jconsole but another client has exhibited the same behavior, and then I tried a programmatic client (code below) with the exactly the same outcome...

What am I missing?

The client code is

public static void main(String[] args) throws Exception
{
final String host = "myhost";
final int port = 8184;
final int namingPort = 8183;

final String jmxUrl =
"service:jmx:rmi://" + host + ":" + port +
"/jndi/rmi://" + host + ":" + namingPort + "/server";
final JMXServiceURL url = new JMXServiceURL(jmxUrl);

Map<String,Object> env = new HashMap<String,Object>();
String[] credentials = new String[] { "user" , "pwd" };
env.put("jmx.remote.credentials", credentials);

JMXConnector jmxc = JMXConnectorFactory.connect(url, env);
MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();

String[] domains = mbsc.getDomains();
//verify (e.g. print) domain names here
}

-Alex

kjkoster
25-06-2009, 08:22
Dear Alex,

Well, JMX, uses a model where you can have more than one MBean server in a JVM. Note that when you use the local JMX API, you have to call findMBeanServer() on the MBeanServerFactory (http://java.sun.com/javase/6/docs/api/javax/management/MBeanServerFactory.html#findMBeanServer(java.lang. String)) and then you get a list of servers.

Most likely your remote connection only hooks up to the platform mbean server and not to the one that Tomcat resgistered its own domains in?

Check the JDK sources to see what is different between an authenticated and non-authenticated connection with respect to the way it finds the mbean servers. In Eclipse this is probably as simple as [ctrl][click] on the class names.

alexk
25-06-2009, 20:05
Thank you for your reply, as it prompted me to think in the direction of a conflict between connectors...

What I needed to do, and what has solved the problem, was to add a specification for a different (from the one my custom connector is using) listening port (via -Dcom.sun.management.jmxremote.port=) when starting Tomcat. That way the default connector created using the java VM command line parameters no longer conflicts with my custom connector, and I can see tomcat and my custom-created MBeans.

Thanks again!

P.S. Is this the right forum for JMX/Tomcat questions? If not, would you please recommend a better one.

kjkoster
25-06-2009, 20:19
Dear alexk,

Glad to help and glad you solved your problem.

Don't worry too much about what forum to use.

Kees Jan