Hi, I am doing the RMI part of my developer certification. I wrote a Server Interface and the Server Implementation Class, that implements this interface. I used rmic command to create the stub class . The stub class was successfully created and placed in the package. I successfully started the rmiregistry. When I try to run the Server Implementation class so that I could rebind the serverObject name with the registry, it fails with the following error message Exception in thread "main" java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: java.rmi.UnmarshalException: error unmarshalling arguments; nested excep tion is: java.lang.ClassNotFoundException: suncertify.db.DataServerImpl_Stub java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: java.lang.ClassNotFoundException: suncertify.db.DataServerImpl_Stub java.lang.ClassNotFoundException: suncertify.db.DataServerImpl_Stub at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Stream RemoteCall.java:249) at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java: 224) at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:358) at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source) at java.rmi.Naming.rebind(Naming.java:165) at suncertify.db.DataServerImpl.main(DataServerImpl.java:122) Now after looking at the message I got confused, since a line of the message also indicates that it was not able to find the stub class. I went to directory suncertify\db on my system and found the stub class there. Also I feel that my Naming.rebind command is not working properly. Could anybody throw some light upon this?
I am not an RMI guru, however I know that both the stub and the server needs to have access to the class definition(s) of the objects that are being passed across the wire. So make sure you copy the .class file(s) to both the server and client directories and try again.
Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Joined: Nov 13, 2000
Thank you for your reply. I have both the stub class and the server class in the same package. In fact, the whole project is under one package. So both the Server and the stub class have equal access to all the classes. Still I am getting the problem.
Have you made sure that your classpath was cleared (unset) before starting the rmi registry - don't know if this is your problem but it can have strange side effects if there are any classes in your classpath when you start the rmiregistry Hope this helps Conor
My solution to this type of problem was specifying the java.rmi.server.codebase property on the command line when starting the server, like so: java -Djava.rmi.server.codebase=file:/C:/javapps/suncertify/code/ ... That directory is the top of my class tree. This cleared up the problem with finding the stub class. BTW, specifying the codebase incorrectly can lead to AccessControlExceptions (such as typing file://C:/...). [This message has been edited by Brian Besterman (edited June 07, 2001).] [This message has been edited by Brian Besterman (edited June 07, 2001).]
hi, I got similar Exception. when I run my client and server on the same PC, either in local or remote mode, everything is fine. when I put my server on remote site (studsys.mscs.mu.edu). using Naming.list ("rmi://studsys.mscs.mu.edu/") I got rmi://studsys.mscs.mu.edu:1099/RemoteData. when I try Remote data = (Remote)Naming.lookup ("rmi://studsys.mscs.mu.edu:1099/RemoteData"),I got the following: java.rmi.UnmarshalException: error unmarshalling return; nested exception is: java.lang.ClassNotFoundException: suncertify.server.RemoteDataImpl_Stu java.lang.ClassNotFoundException: suncertify.server.RemoteDataImpl_Stub at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at sun.rmi.server.LoaderHandler.loadClass(Unknown Source) at sun.rmi.server.LoaderHandler.loadClass(Unknown Source) at sun.rmi.server.MarshalInputStream.resolveClass(Unknown Source) at java.io.ObjectInputStream.inputClassDescriptor(Unknown Source) at java.io.ObjectInputStream.readObject(Unknown Source) at java.io.ObjectInputStream.readObject(Unknown Source) at java.io.ObjectInputStream.inputObject(Unknown Source) at java.io.ObjectInputStream.readObject(Unknown Source) at java.io.ObjectInputStream.readObject(Unknown Source) at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source) at java.rmi.Naming.lookup(Unknown Source) at suncertify.client.DataClient.<init>(DataClient.java:38) at suncertify.client.Client.<init>(suncertify/client/Client.java:44) at suncertify.client.Client.main(suncertify/client/Client.java:82)
any thought is appreciated! Allen: you said unset classpath, how can you set classpath for rmiregistry ( I don't mean inherit from the parent window)?