关于The MBean class could not be loaded by the default loader repository的解决方法

 

最近项目要用到JMX,开发环境tomcat 5.0.28+jdk 1.5+jmx1.2,采用RMI方式链接,研究过程中出现了The MBean class could not be loaded by the default loader repository这个Exception,通过在网上查找来到了http://archives.java.sun.com/cgi-bin/wa?A2=ind0002&L=jmx-forum&P=3052,这里有对此问题解决方法的详细介绍,如下文:

To avoid the problem you are having, you should remove the JMX classes from the
jre/lib/ext/ directory of your JDK, and put them instead in another directory

that has no special meaning for the JDK.

This problem comes from a bug in the JMX Early Access when used as Java
Installed Extensions, which is what you did. It will be fixed for the final
release of the JMX RI.

What happened here is that, as you had jmxri.jar in the jre/lib/ext/ directory,
a specific Extension Class Loader was used to load the MBeanServer class when
the agent was created
(see
http://java.sun.com/docs/books/tutorial/ext/basics/load.html for more info
on extension class loading).
Then the MBeanServer attempted to load the MBean classes using this same
Extension Class Loader, which would not work because the Extension Class Loader
does not load classes from the classpath.

大概意思就是这个错误是因为JMX本身bug导致的,删除jre/lib/ext下的关于JMX的jar包,在classpath中重新指定jar包的位置就能解决.但是这个是对于早期的JMX而言的,我在自己的机器上查找发现JDK 1.4和1.5的相应目录下都没有关于JMX的jar包.可见JMX本身的bug已经被修复了.那是那方面出的问题呢?

仔细从几个错误中发现,产生此异常的时not found 的MBean都是自己写的,于时将自己写的MBean进行打包,然后进行各种尝试,最后看到了上文的帖子,抱着试一试的想法放入ext下,至此问题解决.

我的这个方法虽然能解决问题,但是我总觉得应该会有更好的方法,不知道你遇到这种情况时是如何解决的呢?

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值