Note that there are some explanatory texts on larger screens.

plurals
  1. PORMI ClassNotFoundException
    text
    copied!<p>Encountering UnmarshalException ClassNotFoundException in RMI while attempting to revoke Remote Method in Netbeans 6.5/windows xp. Both rmi client and server programs are running in the same machine.</p> <p><strong>RMI Client Program:</strong></p> <p>Source Code Location</p> <ul> <li><p>F:\NewRMIClient\src\newrmiclient\RMIClient.java</p></li> <li><p>F:\NewRMIClient\src\newrmiclient\RemoteInterface.java</p></li> </ul> <p>Class Files Location</p> <ul> <li><p>F:\NewRMIClient\build\classes\newrmiclient\RemoteInterface.class</p></li> <li><p>F:\NewRMIClient\build\classes\newrmiclient\RMIClient.class</p></li> </ul> <p>Built JAR File Location</p> <ul> <li><p>F:\NewRMIClient\dist\NewRMIClient.jar</p> <p>RemoteInterface.java</p> <p>package newrmiclient;</p> <p>import java.rmi.Remote; import java.rmi.RemoteException;</p> <p>public interface RemoteInterface extends Remote { void sendMessageFilePath(String messagePath) throws RemoteException; }</p></li> </ul> <p>RMIClient.java</p> <pre><code>package newrmiclient; import java.rmi.*; import java.rmi.registry.*; public class RMIClient { static public void main(String args[]) { RemoteInterface rmiServer; Registry registry; String serverAddress="192.169.4.11"; String serverPort="3232"; String text="hello"; System.out.println("sending "+text+" to "+serverAddress+":"+serverPort); System.setProperty("java.security.policy","file:/F:/PolicyFiles/rules.policy"); if(System.getSecurityManager() == null) { System.setSecurityManager(new RMISecurityManager()); } try{ // get the “registry” registry=LocateRegistry.getRegistry(serverAddress,(new Integer(serverPort)).intValue()); // look up the remote object rmiServer=(RemoteInterface)(registry.lookup("MessagePath")); // call the remote method rmiServer.sendMessageFilePath(text); } catch(RemoteException e){ e.printStackTrace(); } catch(NotBoundException e){ e.printStackTrace(); } } } </code></pre> <p><strong>RMI Server Program:</strong></p> <p>Source Code Location</p> <ul> <li><p>F:\RMIProj\src\rmiproj\RemoteInterface.java</p></li> <li><p>F:\RMIProj\src\rmiproj\RmiServer.java</p></li> </ul> <p>Class Files Location</p> <ul> <li><p>F:\RMIProj\build\classes\rmiproj\RemoteInterface.class</p></li> <li><p>F:\RMIProj\build\classes\rmiproj\RmiServer.class</p></li> <li><p>F:\RMIProj\build\classes\rmiproj\RmiServer_Skel.class</p></li> <li><p>F:\RMIProj\build\classes\rmiproj\RmiServer_Stub.class</p></li> </ul> <p>Built JAR Location</p> <ul> <li>F:\RMIProj\dist\RMIProj.jar</li> </ul> <p>RemoteInterface.java</p> <pre><code> package rmiproj; import java.rmi.Remote; import java.rmi.RemoteException; public interface RemoteInterface extends Remote { void sendMessageFilePath(String messagePath) throws RemoteException; } </code></pre> <p>RmiServer.java</p> <pre><code>package rmiproj; import java.rmi.RMISecurityManager; import java.rmi.server.UnicastRemoteObject; import java.rmi.RemoteException; import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; public class RmiServer extends UnicastRemoteObject implements RemoteInterface { int thisPort = 3232; Registry registry; // rmi registry for lookup the remote objects. public RmiServer() throws RemoteException { try { System.setProperty("java.rmi.server.codebase","file:/F:/RMIProj/"); System.setProperty("java.rmi.server.hostname","RMIServer"); System.setProperty("java.security.policy","file:/F:/PolicyFiles/rules.policy"); if(System.getSecurityManager() == null) { System.setSecurityManager(new RMISecurityManager()); } // create the registry and bind the name and object. registry = LocateRegistry.createRegistry( thisPort ); registry.rebind("MessagePath", this); } catch(RemoteException re) { re.printStackTrace(); } } // This method is called from the remote client by the RMI. // This is the implementation of the “RemoteInterface”. public void sendMessageFilePath(String messageFilePath) throws RemoteException { System.out.println(messageFilePath); } public static void main(String args[]) throws RemoteException { RmiServer s=new RmiServer(); } } </code></pre> <p>Location of the policy file: F:\PolicyFiles\rules.policy</p> <p>rules.policy grant { permission java.security.AllPermission; };</p> <p>When attempting to invoke remote method from client, following exception is thrown on console:</p> <pre><code>sending hello to 192.169.4.11:3232 java.rmi.UnmarshalException: error unmarshalling return; nested exception is: java.lang.ClassNotFoundException: rmiproj.RemoteInterface at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source) at newrmiclient.RMIClient.main(RMIClient.java:28) Caused by: java.lang.ClassNotFoundException: rmiproj.RemoteInterface at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at java.lang.ClassLoader.loadClass(ClassLoader.java:251) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:247) at sun.rmi.server.LoaderHandler.loadProxyInterfaces(LoaderHandler.java:711) at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:655) at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:592) at java.rmi.server.RMIClassLoader$2.loadProxyClass(RMIClassLoader.java:628) at java.rmi.server.RMIClassLoader.loadProxyClass(RMIClassLoader.java:294) at sun.rmi.server.MarshalInputStream.resolveProxyClass(MarshalInputStream.java:238) at java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1531) at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1493) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351) </code></pre> <p>Please help me to resolve this issue.</p>
 

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