RMI中的java.lang.ClassNotFoundException,未禁用安全管理器RMI类加载器

时间:2012-06-19 05:46:54

标签: java rmi distributed-computing

我创建了以下bat文件来运行我的RMI服务器

@echo Off

set classpath=C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\RMI_Server\bin\;
set classpath=C:\policy.all;
set classpath=C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\RMI_Server\log4j-1.2.12.jar;
set classpath=C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\RMI_Server\log4j-1.2.15.jar;
set classpath=C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\RMI_Server\log4j.jar;
set classpath=C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\RMI_Server\log4jProperties.jar;
set classpath=C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\RMI_Server\bcprov-jdk15-144.jar\bcprov-jdk15-144.jar;
set classpath=C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\RMI_Server\sevenzipjbinding.zip;
set classpath=C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\RMI_Server\sevenzipjbinding-AllPlatforms.zip;
set classpath=C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\RMI_Server\apache-log4j-1.2.17\log4j-1.2.17.jar;




set classpath=%classpath%;.

java -Djava.security.manager -Djava.security.policy=C:\policy.all

java -Xms512m -Xmx1024m ExecutorServer -Djava.rmi.server.codebase=file:C:/Program Files/Apache Software Foundation/Tomcat 6.0/webapps/RMI_Server/bin/ -Djava.security.policy=C:\policy.all

pause

我可以运行我的RMI服务器 但是当RMI尝试连接到RMI服务器时,我得到以下异常

Execption in RMI...java.rmi.UnmarshalException: error unmarshalling return; nest
ed exception is:
        java.lang.ClassNotFoundException: ExecutorInterface (no security manager
: RMI class loader disabled)
java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
        java.lang.ClassNotFoundException: ExecutorInterface (no security manager
: RMI class loader disabled)
        at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
        at java.rmi.Naming.lookup(Unknown Source)
        at com.mindcraft.queryExecutor.actionclass.acInsertExecutorDetails.rmiCl
ientCall(acInsertExecutorDetails.java:272)
        at com.mindcraft.queryExecutor.actionclass.acInsertExecutorDetails.execu
te(acInsertExecutorDetails.java:218)

我在运行时给出了政策文件和代码库。我没有得到我在这里缺少的东西。 如何在rmiregistry的路径中添加lcass?

2 个答案:

答案 0 :(得分:1)

  1. 将CLASSPATH设置为10个连续值不起作用。它只取最后一个值。你需要设置它=%classpath%;。您还需要引用名称中带有空格的所有目录。
  2. 将policy.all放在CLASSPATH上毫无意义。
  3. java.lang.ClassNotFoundException: ExecutorInterface确切地说出了什么是错的。该课程不在客户面前。

答案 1 :(得分:0)

简单的解决方案是在客户端项目类路径中添加ExecutorInterface.class或其相关的jar。