Note that there are some explanatory texts on larger screens.

plurals
  1. POJava RMI application failed to run
    primarykey
    data
    text
    <p>I created a simple Java RMI application in netbeans 7.0.1 ( win 7 + jdk 7u1). I have two separate projects:</p> <p>RMI_Client contains:</p> <p>MyClient class:</p> <pre><code>package rmi_client; import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; public class MyClient { public static void main(String[] args) { String msg = "Hello RMI"; rmiInterface stub; Registry reg; try { reg = LocateRegistry.getRegistry("localhost"); stub = (rmiInterface) reg.lookup("Hello"); try { stub.hello(msg); } catch(Exception e) { System.out.println("Remote method exception thrown: " +e.getMessage()); } } catch(Exception e) { System.err.println("Client exception thrown: " + e.toString()); e.printStackTrace(); } } } </code></pre> <p>rmiInterface interface:</p> <pre><code>package rmi_client; import java.rmi.Remote; import java.rmi.RemoteException; public interface rmiInterface extends Remote { void hello(String message) throws RemoteException; } </code></pre> <p>RMI_Server contains:</p> <p>rmiInterface interface - exactly the same as above</p> <p>rmiImpl class:</p> <pre><code>package rmi_server; import java.rmi.RemoteException; public class rmiImpl implements rmiInterface { @Override public void hello(String message) throws RemoteException { System.out.println("Server:" + message); } } </code></pre> <p>MyServer class:</p> <pre><code>package rmi_server; import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; import java.rmi.server.UnicastRemoteObject; public class MyServer { public static void main(String[] args) { try { rmiImpl robj = new rmiImpl(); rmiInterface stub = (rmiInterface) UnicastRemoteObject.exportObject(robj, 0); Registry reg = LocateRegistry.createRegistry(1099); reg.rebind("Hello", stub); System.out.println("Server is ready to listen: "); } catch (Exception e) { System.err.println("Server exception thrown: " + e.toString()); } } } </code></pre> <p>If I'm doing something wrong above please let me know. First I start RMI_Server application, then when I run RMI_Client I get errors:</p> <pre><code>Client exception thrown: java.rmi.UnmarshalException: error unmarshalling return; nested exception is: java.lang.ClassNotFoundException: rmi_server.rmiInterface (no security manager: RMI class loader disabled) java.rmi.UnmarshalException: error unmarshalling return; nested exception is: java.lang.ClassNotFoundException: rmi_server.rmiInterface (no security manager: RMI class loader disabled) at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source) at rmi_client.MyClient.main(MyClient.java:28) Caused by: java.lang.ClassNotFoundException: rmi_server.rmiInterface (no security manager: RMI class loader disabled) at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:554) at java.rmi.server.RMIClassLoader$2.loadProxyClass(RMIClassLoader.java:646) at java.rmi.server.RMIClassLoader.loadProxyClass(RMIClassLoader.java:311) at sun.rmi.server.MarshalInputStream.resolveProxyClass(MarshalInputStream.java:257) at java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1549) at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1511) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1750) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:369) ... 2 more </code></pre> <p>Where is the problem ?</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.
 

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