Note that there are some explanatory texts on larger screens.

plurals
  1. PORMI lookup works but method invocation not
    primarykey
    data
    text
    <h2>UPDATE:</h2> <p>The problem is, that i'm using a kind of 2-way connection.</p> <p>On client side, this works:</p> <pre><code>String a = this.lobby.getMsg(); </code></pre> <p>and this not:</p> <pre><code>this.lobby.login((Player)UnicastRemoteObject.exportObject(player, 0)); </code></pre> <p>and ideas?</p> <hr> <hr> <p>I'm working on a java application which uses RMI for network communication.</p> <p>On one computer everythings works good, but if i try to run it via the internet i ran into problems.</p> <p>It seems, that the client is able to retreive the registry from the server and to lookup the lobby-object. But if the client tries to call the login method of the lobby object via rmi, it takes very long time and i receive the following exception: </p> <p>Strange thing is, that there is the wrong ip(the client ip) mentioned in this exception. And if I run a client on the same machine as the server, it works perfectly.</p> <pre><code>java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: java.rmi.ConnectException: Connection refused to host: &lt;client ip(should be server ip?)&gt;; nested exception is: java.net.ConnectException: Die Wartezeit für die Verbindung ist abgelaufen (=time out) at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:353) at sun.rmi.transport.Transport$1.run(Transport.java:177) at sun.rmi.transport.Transport$1.run(Transport.java:174) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Transport.java:173) at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:553) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:808) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:667) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:722) at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:273) at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:251) at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:160) at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:194) at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:148) at $Proxy0.einloggen(Unknown Source) at Client.login(Client.java:64) </code></pre> <hr> <p><strong>Here is the relevant code:</strong></p> <p>My server class:</p> <pre><code> public static final int RMI_PORT = 55555; public static final String SERVER_IP = "xyz.com"; /** * Startet Spielserver * * @param args */ public static void main(String[] args) { System.out.println("Server starten.."); System.setProperty("java.rmi.server.hostname", SERVER_IP); try { if (System.getSecurityManager() == null) { System.setSecurityManager(new RMISecurityManager()); } Registry registry = LocateRegistry.getRegistry(SERVER_IP, RMI_PORT); Lobby lobby = new LobbyImpl(); UnicastRemoteObject.exportObject(lobby, 0); registry.bind("Lobby", lobby); } catch (RemoteException e) { e.printStackTrace(); } catch (AlreadyBoundException e) { e.printStackTrace(); } } </code></pre> <p>Client class:</p> <pre><code>public Client() { try { Registry registry = LocateRegistry.getRegistry("xyz.com", Server.RMI_PORT); lobby = (Lobby) registry.lookup("Lobby"); } catch (RemoteException e) { e.printStackTrace(); } catch (NotBoundException e) { e.printStackTrace(); } this.gui = new GUI(this); } public void login(String name) throws RemoteException { Player player = new Player(name); this.lobby.login((Player)UnicastRemoteObject.exportObject(player, 0)); } </code></pre> <p>Client startscript:</p> <pre><code>#!/bin/bash SCRIPTDIR=$(dirname $0) java -classpath $SCRIPTDIR/bin Client </code></pre> <p>Server startscript:</p> <pre><code>#!/bin/bash SCRIPTDIR=$(dirname $0) cd ${SCRIPTDIR}/bin rmiregistry 55555 &amp; cd - java -classpath $SCRIPTDIR/bin -Djava.security.policy=$SCRIPTDIR/src/server.policy -Djava.rmi.server.codebase=file:$SCRIPTDIR/bin/ Server killall rmiregistry </code></pre> <p>and last but not least my first (test) policy file:</p> <pre><code>grant { permission java.security.AllPermission; }; </code></pre> <p>what could be the problem?</p> <p>regards</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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