RMI 中的 java.lang.ClassNotFoundException,没有禁用安全管理器 RMI 类加载器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11095061/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
java.lang.ClassNotFoundException in RMI,no security manager RMI class loader disabled
提问by happy
I have created below bat file to run my RMI server
我创建了下面的 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
I am able to run my RMI server but when RMI tries to connect to RMI server I get following exception
我能够运行我的 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)
I have give policy file and code base while running.I am not getting what I am missing here. How to add lcass in rmiregistry's path?
我在运行时提供了策略文件和代码库。我没有得到我在这里缺少的东西。如何在 rmiregistry 的路径中添加 lcass?
回答by user207421
- Setting the CLASSPATH to 10 consecutive values doesn't work. It only takes the last value. You need to set it =%classpath%;. You also need to quote all those directories with spaces in their names.
- Putting policy.all on the CLASSPATH is pointless.
java.lang.ClassNotFoundException: ExecutorInterface
says exactly what is wrong. That class is not present at the client.
- 将 CLASSPATH 设置为 10 个连续值不起作用。它只取最后一个值。您需要将其设置为 =%classpath%;。您还需要引用所有名称中带有空格的目录。
- 将 policy.all 放在 CLASSPATH 上是没有意义的。
java.lang.ClassNotFoundException: ExecutorInterface
准确地说出了什么问题。该类不存在于客户端。
回答by Shubham Pratap Singh
Simple solution is that Add ExecutorInterface.class or its related jar in your client project class path.
简单的解决方案是在您的客户端项目类路径中添加 ExecutorInterface.class 或其相关的 jar。