Eclipse RCP, RMI and Bundles

删除回忆录丶 提交于 2019-12-13 02:16:13

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/4650619/eclipse-rcp-rmi-and-bundles

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!