File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Distributed Java and the fly likes Problem while starting rmi server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "Problem while starting rmi server" Watch "Problem while starting rmi server" New topic

Problem while starting rmi server

Chandra Bairi
Ranch Hand

Joined: Sep 12, 2003
Posts: 152
hello friends,
i am new to RMI. i have written the first program in Rmi and after writing them i have created the stubs and skeletons. I started the rmi registry. when i started the rmi registry by issuing the following command
start registry
the following appeared in a new dos window.
"security propertied not found. using defaults".
then i tried to start the rmiserver.
i issued the following command
java HelloServer
but i get the following in the command prompt:

E:\learnjava21\testrmi>java HelloServer
java.rmi.ServerException: Server RemoteException; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested excep
tion is:
java.lang.ClassNotFoundException: HelloServer_Stub
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknow
n Source)
at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Unknown Source)
at HelloServer.main(
Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested ex
ception is:
java.lang.ClassNotFoundException: HelloServer_Stub
Caused by: java.lang.ClassNotFoundException: HelloServer_Stub
kinldy help me out as to how to begin.
i have all the files src,class, stub, skeleton and server.policy files in the same directory and the server and client are also running on the same machine.
Thanks for any help

Chris Shepherd
Ranch Hand

Joined: Jun 27, 2000
Posts: 286
looks like it can't see your stub. Also, you don't need skeleton if you are using v1.2 or higher. Create your stub this way. use the -1.2 speciffically no matter what higher version you are using.

now, on to your real issue... the missing stub.
First off are you using packages for your code? Like your code is in you.yourtest.HelloServer_Stub? If it is, make sure to include the package when making the stub as I do in my example.
Next, you may need to tell java what your codebase is in your java call. Include something like this

I'm pointing to a jarfile that contains my stub, but you can point to either the exact directory where your stub is(no package in your code) or to the directory where the base of your package tree lives(packages in code). Also, don't copy and paste my example because the file location is structured for linux, but use the same format with windows directory location. I know this is really deep for just learning RMI, but keep playing with it.
Try this stuff and see if it makes any difference. Post back if you have more questions.
Chandra Bairi
Ranch Hand

Joined: Sep 12, 2003
Posts: 152
hello chris
thanks for the reply and i have tried out as said by you exactly but i am still getting the same old problem. i have made a jar of the HelloServer_Stub.class which is server.jar and I have also used the same command as the one told by you to create the stub class i.e
rmic -v1.2 HelloServer
the command which i have given to run the rmi server is as follows
E:\learnjava21\testrmi>java -Djava.rmi.codebase="e:\learnjava21\testrmi\server.jar""./rmi1/server.policy" rmi1.HelloServer
but I am getting the same error. i have the classpath pointing to
what could be the error?
Chris Shepherd
Ranch Hand

Joined: Jun 27, 2000
Posts: 286
hmmm are you still getting the
"security propertied not found. using defaults"
When you start the registry? Try taking that out and getting the simple form to work. You can add the security stuff after you get it working.
so your registry isn't binding your stub...
Does your registry live in the same directory as the jar file you made or are you running it out of the java directories?
Can you show me your code in the server where you are trying to bind the stub to the registry? You might also want to consider creating the registry from inside your server. That way you have a clean registry every time you run the server since the registry dies when your program does. I think you only need an external registry when you are using multiple servers, or remote servers from where the registry is running. Especially for test/learning purposes, open it from inside... that way you also know that your registry shares the same path and settings as your program does. Here is the code I use to do that:

Try starting the registry inside your server before you do your rebind() and let me know what happens.
[ November 07, 2003: Message edited by: Chris Shepherd ]
Chris Shepherd
Ranch Hand

Joined: Jun 27, 2000
Posts: 286
oop, had a thought reading another post. With the internal registry, you may need to call your classpath when you call java so it will specifically include your jar file. Just having the jar file's directory included isn't good enough I don't think. change your
to something like this (and leaving out the security policy)

I know you can't see jars in a directory on the classpath, as they are treated like directorys when java is looking for the class files. You have to specify them as part of the classpath.
debasis chakraborty

Joined: Nov 08, 2003
Posts: 4
You try it to change the policy file.
Allow to all
Chandra Bairi
Ranch Hand

Joined: Sep 12, 2003
Posts: 152
package rmi1;
import java.rmi.*;
import java.rmi.server.*;
import java.rmi.registry.*;
public class HelloServer extends UnicastRemoteObject implements Hello
String name;
public HelloServer(String s) throws RemoteException
Registry r=java.rmi.registry.LocateRegistry.createRegistry(1099);
public String sayHello()throws RemoteException
return "hello welcome to rmi";
public static void main(String[] a) {
System.setSecurityManager(new RMISecurityManager());
//Registry reg = new LocateRegistry.createRegistry(1099);
HelloServer obj = new HelloServer("HelloServer");
System.out.println("hello server bound in registry");
catch(Exception e)
Hello Chris
the code for the server object implemenatation is as above. I am still getting some problems while I run the server.
i have used the same command as told by you but since the server object is in rmi1 package. I just added rmi1.HelloServer. this time i get a no main method exception in the class HelloServer i.e the error is as follows:
Exception in thread "main" java.lang.NoClassDefFoundError: rmi1\HelloServer
what could be the problem. also when i run the rmi registry the registry is running from the following location:
C:\program files\oracle\jre\1.1.7\bin\rmiregistry.exe
but i have the java installed in d:\software\java
will this cause a problem.
thanks once again for the help.
Chris Shepherd
Ranch Hand

Joined: Jun 27, 2000
Posts: 286
ok, a couple of things I see right off.
First, you need to start the registry inside of your main statement before you try to do the rebind. Second, you need to include "rmi:"before your rebind string. Third, I think you have to include the package(rmi1) with the server classname in the bind. Here's how it should look:

Make sure you take the other registry call out of your HelloServer().
Another thing I noticed is that you mentioned running the registry out of some directory. You shouldn't have to run the registry by hand at all with your code now because it includes the built in java call to start it.
Try these few changes and see where it gets you. You should be pretty close.
[ November 11, 2003: Message edited by: Chris Shepherd ]
I agree. Here's the link:
subject: Problem while starting rmi server
It's not a secret anymore!