Question

I am trying to do some testing using RMI.

I have a .jar file having the classes with methods I need to call. On my netbeans projects I have a class TestClient which has to connect to ShareBroker which is my Remote interface. My problem is how to set the correct address for java.rmi.server.codebase and which address I need to have in my TestClient in order to lookup for ShareBrooker.

I have tried a number of different addresses and combinations but couldn't get this to work. For this test I need to have the codebase set on a local directory.

Was it helpful?

Solution

The java.rmi.server.codebase property is set at JVMs which export remote objects. Normally this is the server JVM.

The codebase URLs have to refer to a directory or JAR file that is accessible by clients of this server. So it has to be either an HTTP or FTP URL referring to a web server that is accessible by the client, or a file: URL referring to the client's local file system.

In the latter case, (1) the server would have to know the layout of the client's file systemic order to set the codebase property correctly, which presents a configuration difficulty, and (2) all it would be accomplishing is something that would just as well be accomplished by including that local directory/JAR file in the client's CLASSPATH and leaving the codebase system out of it altogether.

In other words there is absolutely no point in a codebase that refers to a local file system.

OTHER TIPS

Please check your remote interface may not extend java.rmi.Remote interface

For the client to access the remote service you should have the stubs available to the client.This can be set in the clients classpath(You can include the generated stubs in the projects build path).

The java.rmi.server.codebase property has to be set in the remote service if the client doesn't have the stubs in its classpath.If this is set ,when the client invokes the remote method it will download the stub class from the codebase specified.

Following links might be useful.. https://community.oracle.com/thread/1180559?start=0 http://docs.oracle.com/javase/7/docs/technotes/guides/rmi/codebase.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top