mostafa88
mostafa88

Reputation: 542

Error on binding in registry when using RMI

I write a simple program using RMI. When I want to bind a service to registry, it throws this exception:

java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: 
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: 
java.lang.ClassNotFoundException: hw2.RMI.Server.RMIServer_Stub

Also in the RMI VM properties, value of java.rmi.server.codebase, I use compute from classpath button that generate this 2 URL:

file:${workspace_loc:/rmiServer/bin} ( server)
file:${workspace_loc:/rmiInterface/bin} ( interface)

I use java-open jdk64 && JRE system library [JavaSE-1.6] && install eclipse plugin from this site

I can't find any good solution to solve my problem, can anyone help me?

Upvotes: 1

Views: 957

Answers (2)

TheJanOnline
TheJanOnline

Reputation: 9

I remember that I read somewhere (looks like here: http://docs.oracle.com/javase/6/docs/technotes/guides/rmi/codebase.html, section 6.0) that if you use directories in java.rmi.server.codebase, you need to end it with trailing slash.

On the other hand, running standalone RMI registry with classpath is trivial: you need to set CLASSPATH env variable and then run rmiregistry in your shell. Worked for me even with no java.rmi.server.codebase specified when launching server.

BTW. If you need some examples of file: URL format accepted by java.rmi.server.codebase, you can find some here: http://docs.oracle.com/javase/tutorial/rmi/running.html

Upvotes: 1

user207421
user207421

Reputation: 310979

The Registry doesn't have the named class available on its CLASSPATH. In general there are three solutions:

  1. Figure out how to run rmiregistry with a CLASSPATH argument, or
  2. Run it inside your server JVM, via LocateRegistry.createRegistry().
  3. Use the codebase feature.

You are trying to use the codebase feature, but with file: URLs. This won't work unless both the Registry and the clients can use those file: URLs, which can only be the case if they refer to shared drives in a LAN, in which case you don't really need the codebase feature at all really. Use http or ftp URLs, and have them refer to JAR files, not directories.

Upvotes: 0

Related Questions