Results 1 to 2 of 2
  1. #1
    Aaron D is offline Member
    Join Date
    Apr 2011
    Posts
    6
    Rep Power
    0

    Default RMI RemoteException Problem

    Hi all,

    I am experimenting with creating a very basic IM app in which two or more clients can connect to a server, and send messages, which will then be broadcast to all clients. I am using RMI so that upon sending a message to the server, the client can then invoke the method on the server to read a stream and then process the input accordingly.

    However when I try and run the server, I get a RemoteException. Here is my code to initialize the server;
    Java Code:
    public Server() throws RemoteException
    	{
    		try
    		{
    			Naming.rebind("Aaron_Server", this);
    		}
    		catch(MalformedURLException e)
    		{
    			System.out.println("Error Block 1: " + e);
    		}
    		
    		try
    		{
    			System.out.println("Bound");
    			ServerSocket listener = new ServerSocket(1234);
    			client = listener.accept();
    		}
    		catch(Exception e)
    		{
    			System.out.println("Error Block 2: " + e);
    		}
    		try
    		{
    			in = client.getInputStream();
    			out = client.getOutputStream();
    			RClient = (RemoteClient)Naming.lookup("rmi://localhost/IM_Client");
    			ServerRun.addClient(RClient.getName());
    		}
    		catch (IOException ioe)
    		{
    			System.out.println("Error Block 3: " + ioe);
    		}
    		catch (NotBoundException nbe)
    		{
    			System.out.println("Error Block 4: " + nbe);
    		}
    	}
    This seams to run without throwing any of these errors, however the class with the main() method that initialises the server throws the following error:

    Java Code:
    Error Block 7: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: 
    	java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: 
    	java.lang.ClassNotFoundException: com.aaron_durant.im_server.RemoteServer
    Here is the code from the main() method:
    Java Code:
    try 
    		{
    			svr1 = new Server();
    			System.out.println("Created");
    		} 
    		catch (Exception e)
    		{
    			System.out.println("Error Block 7: " + e);
    		}
    Eclipse forces me to declare that the constructor for the server throws a RemoteException, but I do not understand why it is being thrown as the code seems to run properly. However this error stops me from connecting a client to it.

    Please could someone explain this problem to me and help me to fix it.

    Thanx

    Aaron

  2. #2
    achmadlutfi is offline Member
    Join Date
    Nov 2011
    Posts
    2
    Rep Power
    0

    Default Re: RMI RemoteException Problem

    try to change "Naming.rebind("Aaron_Server", this);" with your ip address. Hope this can help you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •