This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes headache of rmiregistry Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "headache of rmiregistry " Watch "headache of rmiregistry " New topic

headache of rmiregistry

James Du
Ranch Hand

Joined: Mar 23, 2001
Posts: 186
Hi, guys
I encountered a problem: I cant bind my remote object to the rmiregistry service.
My working steps is as follows:
1) In the current directory (let's suppose it is D:\\server\) I created the remote object class -
DataImpl(certainly there's also the remote interface), in its main method, I wrote the code:
DataImpl di = new DataImpl();
Naming.rebind("test", di);
catch(Exception e)
2) run the javac to create the .class files: javac *.java.
I found all the .class files are correctly created in the directory.
3) rum the rmic to create the stub class: rmic -v1.2 DataImpl.
I found the expected DataImpl_Stub.class is also correctly created in the directory.
4) from c:\\ run the rmiregistry: rmiregistry
I made the directories different intentionally for i assumed they are not necessarily to be the same.
5) as I hava no HTTP Server installed in my pc, i intended to use file protocol for the
java.rmi.server.codebase property.
I made the "D:\\server\" directory sharable and it's sharing name is "server"
6) from D:\\server\ (where the DataImpl and its stub class reside) run the java:
java DataImpl -Djava.rmi.server.codebase="file://James/server/"
("James" is the name of my pc)
It reported RemoteException and its nested Exception is UnmarsalExcepton and its nested Exception is
ClassNotFoundException: DataImpl_Stub.
Anyone has some clues? if I use file protocol, do i also need to use sth like a File Server to service the incoming request? I assumed my Win98 has the built-in service and could do it automatically, for i could see the contents of the directory from other pc using "file://james/server/".
In the step 4), if i started the rmiregistry from "D:\\server\", it works even without the codebase property, how strange!

How rmiregistry get to know the location of the registried objects? I think the codebase propery specifies not only the location of the remote object but also the protocol the clients could require the stub, if no protocol given, In which way clients could download the stub class? the problem really drives me nuts!
Any reponse and analyse is greatly appreciated
Thanks in advance
- James Du
[ March 09, 2002: Message edited by: James Du ]
James Du
Ranch Hand

Joined: Mar 23, 2001
Posts: 186
Hi, it's still me.
I found a mistake in the step 6), that's the commandline : java DataImpl -Djava.rmi.server.codebase="file://James/server/" is wrong, the codebase property must go before DataImpl or JVM will take the property as null.
So, I changed the commandline as
java -Djava.rmi.server.codebase="file://James/server/" DataImpl. But it still dont work
I'm wondering if the codebase property is a must for running RMI application
- James
Hai Yee

Joined: Jan 03, 2001
Posts: 11
I have encountered a simliar problem, though not exactly as you had described.<br>It turns out that I have multiple JVM's installed in my machine. When I typed "rmiregistry", an earlier version (of JDK1.1) got started instead of (JDK1.3). And when I start the application, I get the message of stub class not found.<br>So you could try starting your rmi registry with command "c:\jdk1.3\bin\rmiregistry" and your application with command "c:\jdk1.3\bin\java ...". The same goes for "rmic". This way, you will know exactly what version you are using.

James Du
Ranch Hand

Joined: Mar 23, 2001
Posts: 186
Thanks Hai Yee.
I kept trying and trying various parameters combination and happened to come across the solution, the key lies in the URL format, i changed the codebase property as file:/d:\server/ rather than file://James/server/ and it do worked!
And then i tried my client, it turned out that there must have an entry as
permission "d:\\server\\-", "read";

in the policy file for client to download the stub class.
There arised the new problem: How does it work if the server and the client are in the different machine
Or maybe RMI does not support it at all?
It is sorta covered in the JavaRanch Style Guide.
subject: headache of rmiregistry
It's not a secret anymore!