• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

rmi stub problem

 
amod gole
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
i am facing one problem in rmi programming.
it is simple one but

here is my interface

import java.rmi.*;
public interface AddServerIntf extends Remote
{
double add(double d1,double d2) throws RemoteException ;

}

//***************server code


import java.rmi.*;
import java.rmi.server.*;
import java.net.*;
public class AddServerImpl extends UnicastRemoteObject implements AddServerIntf

{
public AddServerImpl()throws RemoteException
{
}


public double add(double d1,double d2)throws RemoteException
{
return(d1+d2);

}
public void call()throws Exception
{
AddServerImpl a=new AddServerImpl();
System.out.println("Server Is started");
Naming.rebind("a",a);
System.out.println("Server Is started");
}
public static void main(String [] args)
{
try
{
System.out.println("Server Is started");
AddServerImpl a=new AddServerImpl();
a.call();

}
catch ( Exception e)
{
System.out.println("Exception:"+e);

}
}
}

//************client code
import java.rmi.*;
public class AddClient
{
public static void main(String[] args)
{
try
{
AddServerIntf b= (AddServerIntf)Naming.lookup("a");
System.out.println("the first no is :"+args[1]);
double d1=Float.parseFloat(args[1]);
double d2=Float.parseFloat(args[2]);
System.out.println("the sum is :"+b.add(d1,d2));

}

catch (Exception e)
{
System.out.println("Exception is :"+e);

}


}
}

/*all programs compile well
but when i am running my server it is throwing an exception
my output is
Server Is started
Server Is started
Exception:java.rmi.ServerException: RemoteException occurred in server thread; n
ested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested excep
tion is:
java.lang.ClassNotFoundException: AddServerImpl_Stub

please help me....

thank you
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe your problem is that the rmiregistry needs the Stub classes on its classpath, but isn't finding them.

MOving this to the "Distributed Java" forum for followup.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ernest is right - the rmiregistry can't find your stub class. The way to fix this is to set the codebase property when running your server.
 
amod gole
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for reply,


same code is working on different machine.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic