您的位置:首页 > 编程语言 > Java开发

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

2007-03-05 22:07 1261 查看
 

最近项目要用到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下,至此问题解决.

我的这个方法虽然能解决问题,但是我总觉得应该会有更好的方法,不知道你遇到这种情况时是如何解决的呢?
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐