• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Not Finding Stub

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 1638
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!