127.0.0.2 address appearing out of nowhere!

I made a trivial console-based chat application to learn RMI and the callback feature. It works when I run it at the same computer, but when I start the server part on the linux box and then try to connect to it with the client part (by specifying the server address 192.168.1.103 as argument) from windows i get this exception:

java.rmi.ConnectException: Connection refused to host: 127.0.0.2; nested excepti

on is:

java.net.ConnectException: Connection refused: connect

at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:601)

at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:198

)

at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184)

at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:110)

at callback.ServerImpl_Stub.addClient(Unknown Source)

at callback.ClientMain.main(ClientMain.java:43)

Caused by: java.net.ConnectException: Connection refused: connect

at java.net.PlainSocketImpl.socketConnect(Native Method)

at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)

at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)

at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)

at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)

at java.net.Socket.connect(Socket.java:519)

at java.net.Socket.connect(Socket.java:469)

at java.net.Socket.<init>(Socket.java:366)

at java.net.Socket.<init>(Socket.java:179)

at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirect

SocketFactory.java:22)

at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMaster

SocketFactory.java:128)

at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:595)

... 5 more

...so where does this 127.0.0.2 address come from?! I can ping the machines from each other and the firewall on the linux is off. Java on both machines is java SE6

here are my interfaces:

publicinterface ServerIntextends Remote{

publicvoid addClient(ClientInt client)throws RemoteException;

publicvoid removeClient(ClientInt client)throws RemoteException;

publicvoid publish(String clientID, String msg)throws RemoteException;

}

publicinterface ClientIntextends Remote{

publicvoid notify(String msg)throws RemoteException;

public String getID()throws RemoteException;

}

and here are the main classes that manages objects which implement my remote interfaces (ClientImpl and ServerImpl):

publicclass ServerMain{

/** Creates a new instance of ServerMain */

public ServerMain(){

}

/**

* @param args the command line arguments

*/

publicstaticvoid main(String[] args){

ServerImpl server =new ServerImpl();

try{

LocateRegistry.createRegistry(1099);

ServerInt stub = (ServerInt)UnicastRemoteObject.exportObject(server, 0);

Registry registry = LocateRegistry.getRegistry();

registry.bind("MyServer", stub);

System.err.println("Server ready");

}catch (Exception ex){

ex.printStackTrace();

}

}

}

publicclass ClientMain{

/** Creates a new instance of ClientMain */

public ClientMain(){

}

/**

* @param args the command line arguments

*/

publicstaticvoid main(String[] args){

String host = args[0];

String clientName = args[1];

ClientImpl client =new ClientImpl(clientName);

try{

Registry registry = LocateRegistry.getRegistry(host);

ServerInt localStub = (ServerInt) registry.lookup("MyServer");

UnicastRemoteObject.exportObject(client,0);

localStub.addClient(client);

BufferedReader keyboard =new BufferedReader(new InputStreamReader(System.in));

String userInput ="";

while(!userInput.equals("quit")){

userInput = keyboard.readLine();

localStub.publish(clientName, userInput);

}

localStub.removeClient(client);

UnicastRemoteObject.unexportObject(client,false);

System.out.println("Connection to Server closed");

}catch (Exception ex){

ex.printStackTrace();

}

}

}

EDIT: the server is started with java -classpath D:/Java/ -Djava.rmi.server.codebase=file:D:/Java/ callback.ServerMain

and to connect with a client:

java -classpath D:/Java/ callback.ClientMain serverAddr myNick

Message was edited by:

dadox01

[6923 byte] By [dadox01a] at [2007-11-27 1:43:56]
# 1
What does the linux hosts file say? They are notorious for being installed incorrectly 'out of the box'.
ejpa at 2007-7-12 1:02:29 > top of Java-index,Core,Core APIs...
# 2

hmmm I am not so good in linux, sry. I used it because I needed a second computer to test the app. Do you mean some of the host* files in /etc/ ? I am using a openSuse 10.2 distro, configured to get the IP from DHCP.

The thing is that when I start the server on the windows pc, and try to connect with a client from linux pc, the same exception occurs (at the client side, the server seems running fine)

dadox01a at 2007-7-12 1:02:29 > top of Java-index,Core,Core APIs...
# 3
Yes so what does /etc/hosts say on Linux? and what is the machine's hostname?
ejpa at 2007-7-12 1:02:29 > top of Java-index,Core,Core APIs...
# 4

Sry I was away for the weekend; so the machine's hostname is "revers"; here is what's inside the /etc/hosts file:

#

# hosts This file describes a number of hostname-to-address

#mappings for the TCP/IP subsystem. It is mostly

#used at boot time, when no name servers are running.

#On small systems, this file can be used instead of a

#"named" name server.

# Syntax:

#

# IP-Address Full-Qualified-Hostname Short-Hostname

#

127.0.0.1localhost

# special IPv6 addresses

::1 localhost ipv6-localhost ipv6-loopback

fe00::0 ipv6-localnet

ff00::0 ipv6-mcastprefix

ff02::1 ipv6-allnodes

ff02::2 ipv6-allrouters

ff02::3 ipv6-allhosts

127.0.0.2revers revers

Btw I tried the app with another 2 pcs in another network, vista + xp and it worked fine.

dadox01a at 2007-7-12 1:02:29 > top of Java-index,Core,Core APIs...
# 5
Just as I thought. It's not 'appearing out of nowhere' at all, it's appearing out of your hosts file. If the machine's hostname is 'revers' the IP address in the /etc/hosts file should be its external IP address on the subnet, not 127.0.0.2.
ejpa at 2007-7-12 1:02:29 > top of Java-index,Core,Core APIs...
# 6
FIXEDIt seems that the problem was within the Cisco VPN client software that was installed on the XP machine. I had to turn off the stateful firewall within. This firewall was running even if the client application wasn't!Now all works fine.Thank you for your help!
dadox01a at 2007-7-12 1:02:29 > top of Java-index,Core,Core APIs...