running rmi server, classnotfound [duplicate]

Run the rmiregisrty command from your /bin, /build, or /build/classes folder, whichever folder is the root of your built files.

I spent half a day trying to solve that same thing.


The exception is occurring because the rmiregistry application doesn't know where to load classes from. When you attempt to bind an object in the RMI registry, the registry downloads the class definition for that object. Some of the other answers are telling you to get around this by setting the classpath for the rmiregistry app so that it has the class definitions when it is started and doesn't need to download anything, but Sun's Java RMI tutorial explicitly says not to do this. I suspect this has the potential to cause conflicts between the version of the class in the registry and the class on the server.

The correct way to handle the problem is to set the java.rmi.server.codebase property as you were trying to do. The property requires that a directory path be terminated with a forward slash, like so:

-Djava.rmi.server.codebase=file:${workspace_loc}/progInternet2008/

You may also be having trouble if the ${workspace_loc} variable is a relative path and the rmiregistry application was not started in the same directory so the relative path is not correct for it. If you either make the path absolute, or start the rmiregistry in the appropriate directory, the ClassNotFoundException should go away. See the tutorial on the java.rmi.server.codebase property for a little more detailed information.


Okay I just overcame this problem. Make sure when you run rmiregistry that your CLASSPATH environment variable is set.

For example, you might have a script:

set CLASSPATH=[path to jdbc driver].jar
rmiregistry.exe

This was all I needed to get my lost classpath working. I'm not sure how to send -cp commandline to rmiregistry.exe. Its documentation is quite lacking.


I'm fairly certain that you'll have to start your RMI server using the same classpath as your application. I believe it takes the same parameters as java, i.e. -cp [your class path].


Close the cmd window where the rmiregistry was initially started.In a fresh cmd go to the location where your project classfiles are located(uptill bin) and start the registry using the below command:

rmiregistry -J-Djava.rmi.server.useCodebaseOnly=false

If you are using Eclipse ,Run the ServerSideProject and your ImplementationClass Instance gets bound to the URL specified.

Just print a line below the the binding method and see to it whether it is gets printed. If it gets printed successfully it means your server is working fine.