RMI激活奇怪问题
我正在尝试让 RMI 可激活服务器工作 - 但到目前为止还没有运气。实际上服务器似乎运行了,但是客户端触发了一个奇怪的异常。
我有3个项目:
- 客户端
- common
- 服务器
Common 是客户端和服务器之间的共享代码(例如远程接口)。
我遵循的步骤(一直在改编 本教程):
- 启动注册表 -->确定
- 运行 rmid --> OK
- 开始服务器设置 --> OK
- 启动客户端 --> 轰!激活失败,因为在服务器线程中未找到 common 中的类并出现 NoClassDefFoundError。
我将公共类文件包含在服务器的代码库中,以便服务器可以使用这些类/接口。它在远程接口本身上失败了 - 所以唯一的选择似乎是将所有公共代码拉到服务器代码中,但这样客户端代码将必须了解服务器代码,这很糟糕。
我浏览了一下,看起来像这个人在这里遇到了完全相同的问题。
看起来在这两种情况下,当可激活服务器引用其他包中的类(在我的例子中,它是第三方链接中的自定义包)时,就会发生这种情况。
我真的很茫然 - 所以任何想法将不胜感激!
编辑:一些附加信息 - 我正在尝试调试问题。看来客户端很好地检索了主题中的远程对象(引用不为空)。一旦调用远程接口的方法(客户端知道该接口),就会抛出异常。如果激活发生在第一次方法调用时,那么这是非常明显的 - 但不太确定它何时实际尝试激活远程对象/服务器。
I am trying to get an RMI activatable server to work - but no luck so far. Actually the server seems to run, but the client triggers a strange exception.
I have 3 projects:
- client
- common
- server
Common is shared code between client and server (such as remote interfaces).
Steps I follow (been adapting this tutorial):
- start registry --> OK
- run rmid --> OK
- start server setup --> OK
- start client --> BOOM! Activation fails because classes in common are not found with NoClassDefFoundError in the server thread.
I am including the common class files in the codebase for the server so those clases/interfaces should be available to the server. It bums out on the remote interface itself - so the only alternative seems to pull all the common code into the server code, but this way the client code will have to know about the server code which plain sucks.
I did a bit of browsing and looks like this guy here has got the exact same problem.
Looks like in both cases this is happening when the activatable server references classes in some other package (in my case it's a custom package in the link above it's third-parties).
I really am at loss here - so any idea would be appreciated!
EDIT: some additional info - I am trying to debug the problem. It seems that the client retrieves the remote object in subject just fine (the reference is not null). The exception is thrown as soon as a method of the remote interface (the client knows about that interface) is called. If the activation occurs on the 1st method invocation then this is pretty obvious - but not too sure about when it actually tried to activate the remote object/server.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在安装过程中,您是否将 common 包中的类包含在服务器上可激活类的位置中?如果您有多个路径,请确保用空格分隔它们。
Have you included the classes in the common package in the location of the activatable class on the server during setup? If you have more than one path make sure to separate them with spaces.