running rmi server, classnotfound [duplicate]

白昼怎懂夜的黑 提交于 2019-11-26 11:52:58

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.

Nathan Feger

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].

try to add /bin at the end of your VM Arg:

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

The file you will run are in this directory, so you need to include it in the path.

I upgraded from JDK1.6.0_33 to 1.7.0_45 and had the same problem. I found this document and resolved the problem by starting rmiregistry with:

rmiregistry -Djava.rmi.server.useCodebaseOnly=false

Refer below http://docs.oracle.com/javase/7/docs/technotes/guides/rmi/enhancements-7.html

I had the same problem, to fix this ensure that your CLASSPATH is set to the path containing the server classes when running rmiregistry.

On a linux machine run the following commands.

export CLASSPATH="<server_class_path>"

Ensure the CLASSPATH has been set:

echo $CLASSPATH

Once the class path has been set, run rmiregistry

rmiregistry &

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.

Abraham

I spent a whole day uninstalling and reinstalling my JDK and changing the classpaths's and environment variables. But the culprit was that the command start rmigregistry didnt' start rmiregistry in a proper way. So, thanks for the comments on this page the solution was to unset the CLASSPATH temporarily. And that is done through the command set CLASSPATH=

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!