tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Remy Maucherat <>
Subject [PROPOSAL] Re: Tomcat5 MBeans/JMX context creation
Date Mon, 01 Mar 2004 23:40:06 GMT
Randy Watler wrote:

> Remy Maucherat wrote:
>>Randy Watler wrote:
>>>I am currently experimenting with the Java 1.5 remote JMX/MBeans for 
>>>use in our build process.
>>>Can anyone clarify how the "createStandardContext" should be invoked?
>>You can look at the JBoss integration code for examples.
>>There's additional code, but this is for creating a basic context, and 
>>configuring its classloader. The Tomcat code which allows doing this 
>>is a lot more recent than the harcoded admin webapp methods, and is 
>>more JavaBean like.
> Remy,
> Note that I am using the JMX remote "Out-of-the-box" Java 1.5 Monitoring 
> and Management, so some of the JBoss setup may not apply, (like the 
> ClassLoader configuration that passes object instances). Here is what I 
> am trying:
> // create context
> mbeanServer.createMBean( "org.apache.commons.modeler.BaseModelMBean", 
> context,
>                          new Object [] { 
> "org.apache.catalina.core.StandardContext" },
>                          new String [] { "java.lang.String" } ) ;
> mbeanServer.setAttribute( context, new Attribute( "docBase", 
> "/tmp/testsite" ) ) ;
> mbeanServer.setAttribute( context, new Attribute( "path", "/testsite" ) ) ;

 > Unfortunately, the createMBean call above throws the following exception:
 > The MBean class could not be
 > loaded by the default loader repository
 >     at
 > sitory(
 >     at
 >     at
 >     at
 >     at
 > java:1418)
 >     at
 > ava:81)
 >     at
 >     at Method)
 >     at
 >     at
etc, etc

> This makes sense to me perhaps because the JVM does not understand the 
> Tomcat5 ClassLoader hierarchy and cannot load 
> org.apache.commons.modeler.BaseModelMBean, no? Consequently, I am 
> guessing that I am not going to be able to create new MBeans without 
> doing so via existing registered MBeans? Am I missing something that 
> should be obvious? Perhaps Tomcat can register its own "loader 
> repository" somehow?

Well, ok, there's a problem.

You have to use that form of createBean, otherwise it's not going to 
work:  ObjectInstance createMBean(String className, ObjectName name, 
ObjectName loaderName, Object[] params, String[] signature)

The problem is that right now the CL aren't registered in JMX. Woops. 
Better luck next release, I guess ;) (I think I had written somewhere 
that the JMX stuff was "not done yet")

To address this issue, the classloaders used and created by Tomcat 
standalone should be registered with JMX.
The registration will take place:
- in ClassLoaderFactory for the standard classloaders (common, shared 
and server)
- in WebappLoader for the webapp classloaders (the loaders are already 
To avoid dependencies on the rest of the world (commons-*), the 
StandardClassLoader MBean will be a standard MBean (not too hard: no 
attributes or operations are needed).
The webapp classloader only needs an entry in mbeans-descriptors.

Proposed object names for the classloaders:

Main CLs:
Webapps CLs:

I am likely to move jmx.jar to "bin", since bootstrap will need to 
register the CLs it creates. The good thing is that this way all JDKs 
will have JMX in the classpath, like JDK 1.5 has.

Once this "minor" issue is cleared out, this should all work.

Any comments on this ?


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message