wood burning stoves*
The moose likes Distributed Java and the fly likes Not Finding Stub 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 "Not Finding Stub" Watch "Not Finding Stub" New topic
Author

Not Finding Stub

jinesh parikh
Ranch Hand

Joined: Apr 20, 2007
Posts: 48
Hi all i have written the simple programme of rmi and i am running the programme in the jdk1.5.0_06

This is the source code for all of the files in the programme

HelloInterface
----------------------
import java.rmi.*;
import java.rmi.server.*;


public interface HelloInterface extends Remote
{
String sayHello() throws RemoteException;

}

HelloClient
---------------------
import java.rmi.*;
import java.rmi.server.*;

public class HelloClient
{
public static void main(String args[]) throws Exception
{

System.out.println("Hello Client started ");

HelloInterface intf=(HelloInterface) Naming.lookup("/HelloObj");

System.out.println("The Output of the programme:" + intf.sayHello());



}

}


HelloServer (Implementation)
------------------------------
import java.rmi.*;
import java.rmi.server.*;


public class HelloServer extends UnicastRemoteObject implements HelloInterface
{
public HelloServer() throws RemoteException
{
super();
}

public String sayHello() throws RemoteException
{
return "Hello World";
}
}



HelloRegister
----------------------
import java.rmi.*;
import java.rmi.server.*;

public class HelloRegister
{
public static void main(String args[]) throws Exception
{

System.out.println("Hello Register Server started ");

HelloServer obj=new HelloServer();

System.out.println("Hello Server Object Created ");

Naming.rebind("/HelloObj",obj);

System.out.println("The Object Is In the Registry");



}

}

I have generated the class files and also generated the stubs and skeleton files throug the rmic command and set the folder to the classpath.I started the registry but when i am trying to execute the HelloRegister file then it gives me the following exception

Exception in thread "main" java.rmi.ServerException: Server RemoteException; nes
ted exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested excep
tion is:
java.lang.ClassNotFoundException: HelloServer_Stub
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknow
n Source)
at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Unknown Source)
at HelloRegister.main(HelloRegister.java:15)
Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested ex
ception is:
java.lang.ClassNotFoundException: HelloServer_Stub
Caused by: java.lang.ClassNotFoundException: HelloServer_Stub


Please help me!!!i dont'know why this error is coming?
Atif Kalemli
Greenhorn

Joined: Oct 14, 2007
Posts: 1
Hi, all
after compiling execute following command
%JAVA_HOME%/bin/rmic HelloServer

then add HelloServer_Stub.class to client project classpath and
start rmi server
%JAVA_HOME%/bin/rmiregistry &
and bind HelloServer in rmi server
%JAVA_HOME%/java HelloRegister
and run client
%JAVA_HOME%/java HelloClient
jinesh parikh
Ranch Hand

Joined: Apr 20, 2007
Posts: 48
Dear Atif Kalemli,
Thanks for your reply I have tried what you said.

But it still returns the same error .The problem is that same programme i am running on some other machine it works fine.

Please help me
Nitesh Kant
Bartender

Joined: Feb 25, 2007
Posts: 1638

With jdk5 you do not have to generate stubs using rmic. These are automatically generated using Dynamic proxies.
See this link
Your server class must only extend UnicastremoteObject(that your server does). It does not work in a scenario where the Server object just implements remote and is exported using UnicastRemoteObject.exportObject() methods.
You must have the remote interface definition on the client side.


apigee, a better way to API!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Not Finding Stub
 
Similar Threads
RMI return BufferedImage object from remote method
RMI Problem : java.lang.ClassCastException
Error while registring the server object to RMI registry
Problem while starting rmi server
exception in client side