• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

rmi stub problem

 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for reply,


same code is working on different machine.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic