开发遇到问题

The MBean class could not be loaded by the default loader repository

 

jmx-1_2_1-bin

jmxremote-1_0_1

 

 

注册MBean时报错
javax.management.ReflectionException: The MBean class could not be loaded by the default loader repository
 at com.sun.jmx.mbeanserver.MBeanInstantiatorImpl.findClassWithDefaultLoaderRepository(MBeanInstantiatorImpl.java:61)
 at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.createMBean(DefaultMBeanServerInterceptor.java:271)
 at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.createMBean(DefaultMBeanServerInterceptor.java:211)
 at com.sun.jmx.mbeanserver.JmxMBeanServer.createMBean(JmxMBeanServer.java:408)
 at com.huawei.rms.jmx.server.ClientMBeanServer.registerMBean(ClientMBeanServer.java:186)
 at com.huawei.rms.jmx.server.ClientMBeanServer.init(ClientMBeanServer.java:80)
 at com.huawei.rms.jmx.server.interceptor.RMSClientInterceptor.start(RMSClientInterceptor.java:67)
 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:585)
 at

 

 

 

 

First of all, if registerMBean is enough for you then you should stick with it. createMBean introduces exactly the sort of problems you are seeing. It is only really useful if you need to call it remotely, when registerMBean is unavailable.

If you do need to support createMBean, then you'll want to have a look at Chapter 8, "Advanced Dynamic Loading", in the JMX specification at <http://download.java.net/jdk6/docs/technotes/guides/jmx/JMX_1_4_specification.pdf>. (This is the specification for Java SE 6, but this particular aspect hasn't changed since the previous version which is in J2SE 5.0.)

Basically you need to have your URLClassLoader be an MBean and register it in the MBeanServer. The quickest way to achieve this is to use the existing MLet class, which is a subclass of URLClassLoader. However, MLet brings along a whole bunch of functionality which you probably don't need, so I think a better approach would be to define your own ClassLoader MBean like this:

public interface MyClassLoaderMBean {}
 
public class MyClassLoader extends URLClassLoader
        implements MyClassLoaderMBean {
    public MyClassLoader(URL[] urls, ClassLoader parent) {
        super(urls, parent);
    }
}



Then you can either use MyClassLoader where you currently use URLClassLoader, or you can specify your existing URLClassLoader as the parent of the MyClassLoader and give MyClassLoader an empty set of URLs.

 

 

 

 

http://verran.iteye.com/blog/127882

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值