Stub的可执行RMI JAR文件ClassNotFoundException [英] Executable RMI JAR file ClassNotFoundException for Stub

查看:134
本文介绍了Stub的可执行RMI JAR文件ClassNotFoundException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个工作的RMI服务器程序,我可以直接从.class文件编译和执行。

I have a working RMI server program, which I can compile and execute directly from the .class files.

然而,当我尝试创建一个JAR文件时对于这些程序中的每一个,我得到一个 ClassNotFoundException:ChatImpl_Stub 在执行时导致 RemoteException

However, when I am trying to create a JAR files for each of these programs, I got a ClassNotFoundException: ChatImpl_Stub leading to a RemoteException on execution.

我的清单是(加上最后一行空行):

My manifest is (plus an empty line at the end) :

Main-Class: Server
Class-Path: chat-RMI-common.jar

其中chat-RMI -common是一个包含客户端聊天界面的JAR文件。

Where chat-RMI-common is a JAR file containing the Chat Interface for the client.

我成功创建了JAR:

jar cvmf ..\MANIFEST.MF chat-RMI-server.jar *.class

服务器JAR包含ChatImpl_Stub。但是,当我尝试启动JAR文件时会出现异常:

The server JAR does contain ChatImpl_Stub. However the exception shows up when I am trying to launch the JAR file :

java -Djava.rmi.server.codebase="file:chat-RMI-common.jar file:chat-RMI-server.jar"
    -Djava.security.policy=..\security.policy
    -jar chat-RMI-server.jar

Naming.rebind 时会出现异常函数,涉及ChatImpl,被调用(在程序的开头)。

The exception appears when the Naming.rebind function, involving ChatImpl, is called (at the beginning of the program).

我的安全政策:

grant {
    permission java.security.AllPermission;
}

我还记得什么?提前感谢您的时间。

What am I still forgetting? Thanks in advance for your time.

推荐答案

仔细查看堆栈跟踪。注册表无法找到该课程。它需要在Registry的CLASSPATH上。因此,您需要在其CLASSPATH上使用正确的JAR启动注册表,或者更好地使用LocateRegistry.createRegistry()在服务器JVM中启动它。

Have a good look at the stack trace. The Registry can't find the class. It needs to be on the Registry's CLASSPATH. So you either need to start the Registry with the right JARs on its CLASSPATH, or, better still start it inside the server JVM, with LocateRegistry.createRegistry().

这篇关于Stub的可执行RMI JAR文件ClassNotFoundException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆