ClassNotFoundException远程JMX调用失败:...(没有安全管理器:RMI类加载器被禁用

时间:2009-07-29 15:32:09

标签: java jboss rmi jmx

我尝试从Tomcat中调用Web应用程序中的MBean方法。目标MBean在JBoss 4.2.3下运行。 Tomcat和JBoss应用程序都使用相同类型的相同版本的jar,但在调用时我看到以下异常:

Caused by: java.lang.ClassNotFoundException: ...thisClass... (no security manager: RMI class loader disabled)
    at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:375)
    at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:165)
    at java.rmi.server.RMIClassLoader$2.loadClass(RMIClassLoader.java:620)
    at org.jboss.system.JBossRMIClassLoader.loadClass(JBossRMIClassLoader.java:91)
    at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java:247)
    at sun.rmi.server.MarshalInputStream.resolveClass(MarshalInputStream.java:197)
    at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1575)
    at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
    at java.util.ArrayList.readObject(ArrayList.java:593)
    at sun.reflect.GeneratedMethodAccessor164.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
    at java.util.HashMap.readObject(HashMap.java:1030)
    at sun.reflect.GeneratedMethodAccessor163.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
    at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1667)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1323)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
    at java.rmi.MarshalledObject.get(MarshalledObject.java:142)
    at javax.management.remote.rmi.RMIConnectionImpl$6.run(RMIConnectionImpl.java:1513)
    ... 20 more

我认为JBoss不使用自己的类,但是尝试从某个地方下载这个类,并且因“没有安全管理器:RMI类加载器被禁用”而失败。但是如何更改此行为以使用本地已加载的类。或许我误解了这个猜测......?

2 个答案:

答案 0 :(得分:1)

实际上很少需要使用-Djava.rmi.server.codebase属性进行动态类加载,只需将接口和任何序列化类实现编译到客户端和服务器中就会简单得多。

阅读此答案以获取更多详细信息: RMI Question - Where do clients get a definition for remote classes that have not been added to registry?

答案 1 :(得分:0)

您在运行server.include此属性时是否提供了-Djava.rmi.server.codebase属性,它应该可以正常工作。