• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help! problems in running rmi

 
xu peiheng
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
interface:
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface Example extends Remote{
public static String NAME="HelloWorld";
public String HelloWorld(String name)throws RemoteException;
}
implement:
import java.rmi.RemoteException;
import java.rmi.server.RemoteServer;
import java.rmi.server.UnicastRemoteObject;
public class ExampleImpl extends RemoteServer implements Example{
public ExampleImpl()throws RemoteException {
UnicastRemoteObject.exportObject(this,1234);
}
public String HelloWorld(String name){
return "Hello "+name+"!";
}
}
MAIN:
import java.io.IOException;
import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.AlreadyBoundException;
import java.rmi.RemoteException;
public class MAIN {
public MAIN() {
try{
ExampleImpl server=new ExampleImpl();
Naming.rebind(server.NAME,server);
System.out.println("Server has been started");
}catch(MalformedURLException e){
System.out.println("Wrong");
System.err.println(e);
}catch(RemoteException e){
System.out.println("Can't creat object");
System.err.println(e);
}
}
public static void main(String[] args){
new MAIN();
}
}
when I run it (I hava run the rmiregistry)
"java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: rmiexample.ExampleImpl_Stub
"
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You didn't mention it, so... Have you run rmic to produce the stub yet?
 
Tim Holloway
Bartender
Posts: 18414
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your server classes have to be in the CLASSPATH that rmiregistry is running under.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!