aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Problem with RMI - Your advice requested Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Problem with RMI - Your advice requested" Watch "Problem with RMI - Your advice requested" New topic
Author

Problem with RMI - Your advice requested

Seshan Parameswaran
Greenhorn

Joined: Nov 13, 2000
Posts: 10
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?
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
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.

Ajith


Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Seshan Parameswaran
Greenhorn

Joined: Nov 13, 2000
Posts: 10
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.
Jay Johnson
Greenhorn

Joined: Jun 01, 2001
Posts: 1
Hi Seshan
I'm getting exactly the same problem. Did you find a solution yet?
Thanks JJ
Conor Allen
Ranch Hand

Joined: Apr 27, 2001
Posts: 32
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
Brian Besterman
Greenhorn

Joined: Jun 07, 2001
Posts: 2
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).]
xiaolin wu
Greenhorn

Joined: Jan 09, 2001
Posts: 11
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)?

xiaolin wu
Rick Fortier
Ranch Hand

Joined: Jun 04, 2001
Posts: 147
It looks like the JVM cannot find your stub code. Do you have the stub class in your classpath? It needs to be installed there, or set it up so that they are automatically downloaded.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with RMI - Your advice requested