javarmicodebase

RMI codebase, connecting to local codebase


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.


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.