Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problems running RMI

 
Khaled Mahmoud
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having problems running RMI.
I am using Netbeans 5.0 and Java 1.5.0_06

I have created the Service class that implements the Remote inteface.
But when i try to bind the the Service class to the rmi i get the following
exception :
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: tryrmi.HelloServer_Stub

I have even tried the application without using the netbeans.
I generated the stub file using the rmic tool but still get this problem.
This is so frustrating.
Moreover i know that java 5 autogenerates the stub files.So i should not
genereate them myself.

 
Bhavik Patel
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you don't need to generate stub or anything... but not sure for the project you have to generate stubs or not .. Can anyone confirm this ..Hope this will help you ...

public interface myRemote extends Remote{
............all methods must throw RemoteException ---
}
RemoteImpl extends UnicastRemoteObject implements myRemote {
.............
}..
To register the object ----

Registry reg = LocateRegistry.createRegistry(rmiPort);
reg.rebind("RemoteObject", new RemoteImpl());

To look up the object ---

String url = "rmi://" + host + ":" + port + "/RemoteObject";
myRemote obj= (myRemote ) Naming.lookup(url);
 
Bhavik Patel
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you have generated the stub with rmic then delete it ...
 
Liviu Carausu
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Khaled,

You must assure that you start rmiregistry having your stubs in the classpath.

Greetings,
Liviu
 
Khaled Mahmoud
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

You must assure that you start rmiregistry having your stubs in the classpath.


I use rmiregistry command to run the rmi registry
And here is the directory structure

tryrmi
****HelloServer.class (The Server class)
****SayHello.class (The interface that the class implements)
****Main.class (which registers an instance of the HelloServer in the RMI registry)
****HelloServer_Stub.class which is generated when i run the rmic tool.
I run the Main program using the following command
from the directory that contains tryrmi :
java -classpath . tryrmi.Main

Note : When i have deleted the Sub file the exception was :
ClassNotFoundException tryrmi.SayHello

The problem is also happening with NetBeans.I dont know what i am doing wrong???
One more note i forgot to mention : I wrote code
Class.forName("tryrmi.HelloServer_Stub") and no exception is thrown.
Only within the RMI where it does not recogonize the Stub class.

[ October 14, 2006: Message edited by: Khaled Mahmoud ]
[ October 14, 2006: Message edited by: Khaled Mahmoud ]
 
Liviu Carausu
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's left is that the stub classes must also be in the classpath of the Server file where you try to bind the service
 
Khaled Mahmoud
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can i put the sub in the class path of the class that tries to bind the
service???
I tried to run the application using the following command :
java -classpath . tryrmi.HelloServer_stub Main

I got the following Exception :
NoClassDefFoundError exception was thrown.
[ October 14, 2006: Message edited by: Khaled Mahmoud ]
 
Liviu Carausu
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I wanted to say that the stub classes must be also at client because otherwise the stub won't be deserialized.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic