File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Distributed Java and the fly likes rmi stub problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "rmi stub problem" Watch "rmi stub problem" New topic
Author

rmi stub problem

amod gole
Ranch Hand

Joined: Dec 07, 2005
Posts: 83
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

Joined: Jul 08, 2003
Posts: 24166
    
  30

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.


[Jess in Action][AskingGoodQuestions]
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

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.


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
amod gole
Ranch Hand

Joined: Dec 07, 2005
Posts: 83
thanks for reply,


same code is working on different machine.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: rmi stub problem
 
Similar Threads
Java.rmi.RemoteException
Error while registring the server object to RMI registry
exception in client side
Cannot Start RMI Server
Why does RMI naming lookup work on the local host when I give it a garbage name?