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" ) ) ;

// start context
mbeanServer.invoke( context, "start", null, null ) ;

Unfortunately, the createMBean call above throws the following exception:

javax.management.ReflectionException: The MBean class could not be 
loaded by the default loader repository
    at 
com.sun.jmx.mbeanserver.MBeanInstantiatorImpl.findClassWithDefaultLoaderRepo
sitory(MBeanInstantiatorImpl.java:61)
    at 
com.sun.jmx.mbeanserver.MBeanInstantiatorImpl.instantiate(MBeanInstantiatorI
mpl.java:378)
    at 
com.sun.jmx.mbeanserver.JmxMBeanServer.instantiate(JmxMBeanServer.java:1011)
    at 
com.sun.jmx.remote.security.MBeanServerAccessController.createMBean(MBeanSer
verAccessController.java:167)
    at 
javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.
java:1418)
    at 
javax.management.remote.rmi.RMIConnectionImpl.access+100(RMIConnectionImpl.j
ava:81)
    at 
javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMICon
nectionImpl.java:1301)
    at java.security.AccessController.doPrivileged(Native Method)
    at 
javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConne
ctionImpl.java:1395)
    at 
javax.management.remote.rmi.RMIConnectionImpl.createMBean(RMIConnectionImpl.
java:337)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)
    at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
    at java.lang.reflect.Method.invoke(Method.java:494)
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
    at sun.rmi.transport.Transport+1.run(Transport.java:153)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
    at 
sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
    at 
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:7
01)
    at java.lang.Thread.run(Thread.java:566)
    at 
sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteC
all.java:247)
    at 
sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
    at com.sun.jmx.remote.internal.PRef.invoke(Unknown Source)
    at 
javax.management.remote.rmi.RMIConnectionImpl_Stub.createMBean(Unknown 
Source)
    at 
javax.management.remote.rmi.RMIConnector$RemoteMBeanServerConnection.createM
Bean(RMIConnector.java:662)
    at InstallTask.execute(InstallTask.java:84)
    ... 1 more
Caused by: java.lang.ClassNotFoundException: 
org.apache.commons.modeler.BaseModelMBean
    at 
com.sun.jmx.mbeanserver.ClassLoaderRepositorySupport.loadClass(ClassLoaderRe
positorySupport.java:208)
    at 
com.sun.jmx.mbeanserver.ClassLoaderRepositorySupport.loadClass(ClassLoaderRe
positorySupport.java:128)
    at 
com.sun.jmx.mbeanserver.MBeanInstantiatorImpl.findClassWithDefaultLoaderRepo
sitory(MBeanInstantiatorImpl.java:58)
    at 
com.sun.jmx.mbeanserver.MBeanInstantiatorImpl.instantiate(MBeanInstantiatorI
mpl.java:378)
    at 
com.sun.jmx.mbeanserver.JmxMBeanServer.instantiate(JmxMBeanServer.java:1011)
    at 
com.sun.jmx.remote.security.MBeanServerAccessController.createMBean(MBeanSer
verAccessController.java:167)
    at 
javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.
java:1418)
    at 
javax.management.remote.rmi.RMIConnectionImpl.access+100(RMIConnectionImpl.j
ava:81)
    at 
javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMICon
nectionImpl.java:1301)
    at java.security.AccessController.doPrivileged(Native Method)
    at 
javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConne
ctionImpl.java:1395)
    at 
javax.management.remote.rmi.RMIConnectionImpl.createMBean(RMIConnectionImpl.
java:337)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)
    at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
    at java.lang.reflect.Method.invoke(Method.java:494)
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
    at sun.rmi.transport.Transport+1.run(Transport.java:153)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
    at 
sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
    at 
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:7
01)
    at java.lang.Thread.run(Thread.java:566)

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?

Randy Watler
Finali Corporation


Reply via email to