Note that there are some explanatory texts on larger screens.

plurals
  1. POspecial things to do when using rmi + plugins
    primarykey
    data
    text
    <p>I have an application <code>FooApplication</code> (code in <code>foo.jar</code>) with a plugin <code>BarPlugin</code> (code in <code>foo-bar-plugin.jar</code>). The application instantiates an instance of the plugin dynamically. It works great. </p> <p>FooApplication has some functionality accessible via an RMI interface <code>FooRemote</code>. That also works great, except for one thing. <code>FooRemote</code> has a method to access <code>Remote</code> objects exported by plugins, and I get an java.rmi.UnmarshalException when I try to hand out one of those plugins to an RMI client.</p> <pre><code>public interface FooRemote extends Remote { /* other methods */ public RemoteControl getPluginRemoteControl(int i) throws RemoteException; } /** just a named Remote object for debugging purposes */ public interface RemoteControl extends Remote { public String getName() throws RemoteException; } </code></pre> <p>What I am doing in my FooRemoteImpl is the following:</p> <pre><code>/* just a test object */ private static class RC0 extends UnicastRemoteObject implements RemoteControl { public RC0() throws RemoteException { super(); } @Override public String getName() throws RemoteException { return "RC0"; } } @Override public RemoteControl getPluginRemoteControl(int i) throws RemoteException { int j = i; if (j &lt;= 0) return new RC0(); Collection&lt;RemoteControl&gt; rclist = this.model.getApplicationPluginRemotes(); for (RemoteControl rc : rclist) { if (--j == 0) return rc; } return null; } </code></pre> <p>When I call <code>FooRemote.getPluginRemoteControl(0)</code>, it hands out an instance of my dummy class <code>RC0</code>, and works fine from a client. When I call <code>FooRemote.getPluginRemoteControl(1)</code>, it tries to hand out one of the real plugin remotes, and it fails:</p> <pre><code>??? Java exception occurred: java.rmi.UnmarshalException: error unmarshalling return; nested exception is: java.lang.ClassNotFoundException: com.example.plugin.BarPluginRemoteControl (no security manager: RMI class loader disabled) at sun.rmi.server.UnicastRef.invoke(Unknown Source) at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(Unknown Source) at java.rmi.server.RemoteObjectInvocationHandler.invoke(Unknown Source) at $Proxy5.getPluginRemoteControl(Unknown Source) Caused by: java.lang.ClassNotFoundException: com.example.plugin.BarPluginRemoteControl (no security manager: RMI class loader disabled) [ more stuff deleted ] </code></pre> <p>What gives?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload