Results 1 to 2 of 2
- 04-26-2011, 11:58 PM #1
Member
- Join Date
- Apr 2011
- Posts
- 1
- Rep Power
- 0
RMI - getting ClassNotFoundException for my remote interface
I'm going through the tutorial at Getting Started Using Java RMI . Reason is that I am having great problems running an application of my own that uses RMI. I thought I'd go back to basics and see if I could work out what's wrong.
And lo and behold, I can't get the tutorial to run, either!
That's not entirely true: I have got it to run once. Silly me, I didn't record what I did to make it run, and can't replicate this momentous feat.
Anyway...
The tutorial includes all the code: I have written none of it, edited none of it, so for once I cannot be blamed for bad coding. I am trying to get the server class to run. The code is:
The code for the "Hello" interface is simply:Java Code:package example.hello; import java.rmi.registry.Registry; import java.rmi.registry.LocateRegistry; import java.rmi.RemoteException; import java.rmi.server.UnicastRemoteObject; public class Server implements Hello { public Server() {} public String sayHello() { return "Hello, world!"; } public static void main(String args[]) { try { Server obj = new Server(); Hello stub = (Hello) UnicastRemoteObject.exportObject(obj, 0); // Bind the remote object's stub in the registry Registry registry = LocateRegistry.getRegistry(); registry.bind("Hello", stub); System.err.println("Server ready"); } catch (Exception e) { System.err.println("Server exception: " + e.toString()); e.printStackTrace(); } } }
I keep all this in a file on my desktop (makes for short URIs):Java Code:package example.hello; import java.rmi.Remote; import java.rmi.RemoteException; public interface Hello extends Remote { String sayHello() throws RemoteException; }
Therefore the three .class files, when compiled, are located in:Java Code:C:\Users\Benji\Desktop\hello
I first start the RMI registry at the command line, usingJava Code:C:\Users\Benji\Desktop\hello\example\hello
Then I execute a batch file located in C:\Users\Benji\Desktop\hello, which has the following lines:Java Code:start rmiregistry
I have also tried executing from the command line, by doing:Java Code:java -classpath C:\Users\Benji\Desktop\hello example.hello.Server pause
And then:Java Code:cd C:\Users\Benji\Desktop\hello
Whatever method I use, I (almost) inevitably am met with the following bog of errors:Java Code:java -classpath . example.hello.Server
Anyone know what's going on? Pretty please? :eek:Java Code:Server exception: java.rmi.ServerException: RemoteException occurred in server t hread; nested exception is: java.rmi.UnmarshalException: error unmarshalling arguments; nested excep tion is: java.lang.ClassNotFoundException: example.hello.Hello java.rmi.ServerException: RemoteException occurred in server thread; nested exce ption is: java.rmi.UnmarshalException: error unmarshalling arguments; nested excep tion is: java.lang.ClassNotFoundException: example.hello.Hello at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:396 ) at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:250) at sun.rmi.transport.Transport$1.run(Transport.java:159) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Transport.java:155) at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:5 35) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTranspor t.java:790) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport .java:649) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec utor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor .java:908) at java.lang.Thread.run(Thread.java:662) at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Stream RemoteCall.java:255) at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java: 233) at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:359) at sun.rmi.registry.RegistryImpl_Stub.bind(Unknown Source) at example.hello.Server.main(Server.java:61) Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested ex ception is: java.lang.ClassNotFoundException: example.hello.Hello at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source) at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:386 ) at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:250) at sun.rmi.transport.Transport$1.run(Transport.java:159) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Transport.java:155) at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:5 35) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTranspor t.java:790) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport .java:649) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec utor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor .java:908) at java.lang.Thread.run(Thread.java:662) Caused by: java.lang.ClassNotFoundException: example.hello.Hello at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at java.lang.ClassLoader.loadClass(ClassLoader.java:248) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:247) at sun.rmi.server.LoaderHandler.loadProxyInterfaces(LoaderHandler.java:7 11) 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:6 28) at java.rmi.server.RMIClassLoader.loadProxyClass(RMIClassLoader.java:294 ) at sun.rmi.server.MarshalInputStream.resolveProxyClass(MarshalInputStrea m.java:238) at java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1530) at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1492) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1 731) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350) ... 12 more
- 04-27-2011, 03:37 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,406
- Blog Entries
- 7
- Rep Power
- 17
Similar Threads
-
ClassNotFoundException
By meprasobh in forum New To JavaReplies: 2Last Post: 10-17-2010, 03:32 PM -
classNotFoundException
By jyothi.priyanka in forum NetBeansReplies: 5Last Post: 08-24-2010, 10:13 AM -
ClassNotFoundException
By oontvoo in forum Java AppletsReplies: 7Last Post: 05-13-2010, 11:09 PM -
Remote deploy and remote work with JBoss AS
By chalda in forum EclipseReplies: 2Last Post: 03-08-2010, 11:17 AM -
Remote interface for entity bean
By Java Tip in forum Java TipReplies: 0Last Post: 12-28-2007, 10:40 AM


LinkBack URL
About LinkBacks


Bookmarks