Eclipse RCP, RMI and Bundles

2019-07-28 07:58发布

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条回答
我命由我不由天
2楼-- · 2019-07-28 08:48

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.

查看更多
登录 后发表回答