Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I have to configure a RMI environment so that I'm able to use it in a "real" network?
    text
    copied!<p>Because I didn't want to implement a communication protocol for my client-server based application, I implemented a RMI client and a RMI server on both sides for the information exchange between the two components. </p> <p>If I try to use my application by starting the two components on the same machine, everything is working fine. But if I split the components to two different computers (Kubuntu 9.04 within as a virtual machine within an Windows 7 RC environment with disabled firewall and a native Ubuntu 9.04 environment), it seems like the RMI client is not able to execute the methods which are defined on the server side. (Every functions call leads to a RMI exception.)</p> <p>Currently I only set the system property "java.rmi.server.hostname" on both sides to the network interface which should be used for the data exchange and registered the default port for the communication with rmi daemon (?) rmid. </p> <p>Does somebody has an idea what might be going wrong? Do I have to set some other parameters like "java.rmi.server.codebase" (<a href="http://java.sun.com/j2se/1.4.2/docs/guide/rmi/javarmiproperties.html" rel="nofollow noreferrer">http://java.sun.com/j2se/1.4.2/docs/guide/rmi/javarmiproperties.html</a>) to be able to use the RMI functionality within my application?</p> <p>Edit: Okay, here is some additional information for you:</p> <p>In the initialization phase my client tries to establish a connection to the RMI server of server component, which was initialized using the following two methods:</p> <pre><code>private void initialize() { // set ip address of rmi server System.setProperty("java.rmi.server.hostname", ipAddress); // try to register rmi server try { LocateRegistry.createRegistry(Registry.REGISTRY_PORT); } catch (Exception e) { // ignore } } public void start() { System.out.print("starting master control RMI server ..."); try { Naming.rebind("MasterControl", this); } catch (Exception e) { System.out.println("error: could not initialize master control RMI server"); System.exit(1); } // set running flag isRunning = true; System.out.println(" done"); } </code></pre> <p>"ipAddress" is here the ip address of the network interface of the server component.</p> <p>The method which is used by the client component to establish the connection looks like this:</p> <pre><code> public void connect() { // build connection url String url = "rmi://" + masterControlIpAddress + "/MasterControl"; System.out.println(url); System.out.print("connecting to master control ..."); // try to connect to master control server while (connection == null) { try { connection = (MasterControlInterface) Naming.lookup(url); id = connection.register(localIpAddress); } catch (Exception e) { // ignore } if (connection == null) { try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } } } System.out.println(" done"); } </code></pre> <p>As you can see my client calls a function to register the connection at the server:</p> <pre><code>@Override public int register(String ipAddress) throws RemoteException { // add connection to registrationHandler masterControl.registrationHandler.addConnection(ipAddress); // log int connectionCount = masterControl.registrationHandler.getConnectionCount(); System.out.println("slave control (" + ipAddress + ") instance has been registered at the master control server under the following id: " + connectionCount); return connectionCount; } </code></pre> <p>If I run my program using a real network connection, the text "slave control ..." is not displayed on the server side. Therefore I'm not sure, if the function is really called by the client component.</p> <p>After the client component is intialized it tries to notify the server component by calling the following method using it's RMI connection to the server:</p> <pre><code>public void sendInitializationDone() { try { connection.initializationDone(); } catch (RemoteException e) { System.out.println("error: could not send 'initializationDone' message to master control"); System.out.println(e); System.exit(1); } } </code></pre> <p>to set a flag on the server side.</p> <p>The error occures inside this function on the client side:</p> <p>java.rmi.ConnectException: Connection refused to host 127.0.1.1; nested exception is: java.net.ConnectException: Connection refused.</p> <p>I have no idea why the host is here 127.0.1.1 ...</p> <p>@nos</p> <p>Of course, I disabled the windows firewall and the protection mechanismn of Kaspersky Internet Security. I don't think that there is a running firewall in my Kubuntu. In generell it is possible to establish a connection, because I already used scp to copy my program to the other machine.</p> <p>Edit2:</p> <p>Mhhh, after setting the entry in /etc/hosts which refers to the machine to the ip address of the machine it seems to work, but don't really understand why it does ...</p> <p>BR,</p> <p>Markus</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload