Eclipse RCP,RMI和捆绑包 [英] Eclipse RCP, RMI and Bundles
问题描述
我正在尝试将Eclipse RCP与RMI结合使用。为此,我创建了六个捆绑包:
(括号中为依赖项)
- 核心:客户端和服务器的接口
- Server(Core):服务器实现和注册表启动类
- ServerApp(Server):GUI客户端,它基本上只是实例化注册表启动器(并在激活时启动它) )
- 客户端(核心):客户端实现
- ClientApp(客户端):GUI客户端
现在我启动了serverapp,但是我得到了
原因:java.lang .ClassNotFoundException:core.rmi.CallbackServerInterface(没有安全管理器:禁用RMI类加载器)
现在我开始
-consoleLog -Djava.security.policy = java.policy -Djava.rmi.server.codebase = file的服务器: $ {workspace_loc} / core /
(我的java.policy文件在核心插件中)。
我以为问题是类路径。因此,我成为了核心和服务器伙伴:
Eclipse-BuddyPolicy:已注册
核心包清单文件中的pre>
和
Eclipse-RegisterBuddy :核心
在服务器捆绑清单文件中。
这无济于事,因为我遇到了完全相同的错误。
有人知道我在这个地方出了错吗?
解决方案显然,问题是OSGI使用了自己的Classloader。因此,在执行命名绑定之前,我们需要:
Thread.currentThread()。setContextClassLoader(
this.getClass( ).getClassLoader());
此后,服务器就像一个超级按钮一样工作,客户端可以连接。
I'm trying to combine Eclipse RCP with RMI. For that purpose I created six bundles: (In parenthesis are dependencies)
- Core: Interfaces for client and server
- Server(Core): Server implementation and Registry start class
- ServerApp(Server): GUI client which basically just instantiates the registry starter (and starts it on Activation)
- Client(Core): Client implementation
- ClientApp(Client): GUI client
Now I started the serverapp, but I got a
Caused by: java.lang.ClassNotFoundException: core.rmi.CallbackServerInterface (no security manager: RMI class loader disabled)
Now I started the server with
-consoleLog -Djava.security.policy=java.policy -Djava.rmi.server.codebase=file:${workspace_loc}/core/
(My java.policy file is in the core plugin). I thought the problem was the classpath. So I made core and server buddies:
Eclipse-BuddyPolicy: registered
in the core bundle manifest file and
Eclipse-RegisterBuddy: core
In the server bundle manifest file. Which didn't help, since I got the exact same error.
Does anyone know where I could have gone wrong on this one?
So apparently the problem was, that OSGI uses its own Classloader. So before we do the Naming bind we need:
Thread.currentThread().setContextClassLoader(
this.getClass().getClassLoader());
After this, the server works like a charm, and the client can connect.
这篇关于Eclipse RCP,RMI和捆绑包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!