This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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: 24183
    
  34

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
Cannot Start RMI Server
Error while registring the server object to RMI registry
Why does RMI naming lookup work on the local host when I give it a garbage name?
exception in client side