作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 RMI 应用程序的项目。当我可以在 eclipse 下成功测试它们(使用 RMI Plugin )时,我尝试使用 eclipse 的导出功能将它们导出为 jar 文件。
问题是只有一个应用程序可以与导出的 jar 文件正常工作。
java -jar registry.jar
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: common.Registry <-- ???
错误消息显示未找到类。我解压jar文件发现jar文件中很好的导出了该类。
temp> unzip registry.jar
Archive: registry.jar
inflating: META-INF/MANIFEST.MF
creating: client/
inflating: client/ChatClientImpl.class
creating: common/
inflating: common/ChatRoomProvider.class
inflating: common/Entity.class
inflating: common/ChatRoomServer.class
inflating: common/ChatClient.class
inflating: common/Registry.class <<<---
这是从 rmiregistry 捕获的消息:
Exception dispatching call to [0:0:0, 0] in thread
"RMI TCP Connection(2)-146.6.53.181" at Sun Nov 03 20:33:25 CST 2013:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: common.Registry
这是发生错误的代码:
try {
// clients and providers can access with the name Registry
Naming.rebind("Registry", new RegistryImpl()); <--
} catch (Exception e) {
e.printStackTrace();
}
可能是什么问题?为什么jar文件在其jar文件中找不到class文件?
临时解决办法如下:
java -Djava.rmi.server.codebase=file:/WHERE_THE_BIN_IS/bin/ -jar registry.jar
我可以明确指向代码库目录,但相同的代码已经在 jar 文件中。
最佳答案
当我执行 rmiregister 并设置代码库所在的 CLASSPATH 时,此问题得到解决。
export CLASSPATH=SOMEWHERE_THE_LOCAL_BASE_IS_LOCATED
rmiregistry
关于java - 运行可执行 jar 文件时未找到类错误(使用 eclipse 导出的 RMI 应用程序),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19760376/
在我们的数据库表上,我们使用两个唯一的非聚集索引来创建跨四个字段的唯一约束。我们使用两个,因为其中一个字段 ZipCode 是一个可为空的字段。如果表中存在一条包含 ZipCode 的 null 条目
我刚刚开始学习 Rails 3 教程,以便对框架有一点熟悉,但我在生成 schema.rb 时遇到了问题。我的操作系统是 Windows 7 x64、Ruby 1.9.2、MySQL2 gem 0.2
我是一名优秀的程序员,十分优秀!