0

I am trying to build a java chat program. I have 7 classes for server and client altogether.

My errors are as follows when I run any class

    Exception in thread "main" java.rmi.ConnectException: Connection refused to host: 192.168.56.1; nested exception is: 
java.net.ConnectException: Connection refused: connect
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
at sun.rmi.server.UnicastRef.newCall(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
    at java.rmi.Naming.rebind(Unknown Source)
    at ChatServerDriver.main(ChatServerDriver.java:10)
    Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown Source)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown Source)
... 7 more

Here is my ChatServerDriver class

   import java.net.MalformedURLException;
   import java.rmi.Naming;
   import java.rmi.RemoteException;


   public class ChatServerDriver {

public static void main(String[] args) throws RemoteException, MalformedURLException{

    Naming.rebind("RMIChatServer", new ChatServer());

}

}

1 Answers1

0

You haven't started the RMI Registry.

user207421
  • 305,947
  • 44
  • 307
  • 483
  • 1
    @downvoter Have a look at the stack trace. It is being thrown from the `rebind()` method, which tries to connect to the Registry. Really this is ridiculous. – user207421 May 02 '15 at 02:07