Hi
I am having problem executing the RMI-IIOP example as stated in the Getting Started Guide of
Java http://java.sun.com/j2se/1.4.2/docs/guide/rmi-iiop/tutorial.html Here is the source code that i have writte :
Registry.java (The Server)
==================================================================
import java.rmi.Remote;
import java.rmi.RemoteException;
import javax.rmi.*;
import javax.naming.*;
public class Registry extends PortableRemoteObject implements RegistryIntf{
public Registry() throws RemoteException
{
super();
System.out.println("Inside Constructor");
}
public
String sayHello() throws RemoteException
{
return "Hello";
}
public static void main(String arg[])
{
try{
Registry reg = new Registry();
Context initialNamingContext = new InitialContext();
initialNamingContext.rebind("Registry",reg );
System.out.println("The registered properly");
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
}
==================================================================================
RegistryIntf.java (The Remote Interface Class
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface RegistryIntf extends Remote{
public String sayHello() throws RemoteException ;
}
=========================================================
Th client class
==========================================================
import java.rmi.RemoteException;
import java.net.MalformedURLException;
import java.rmi.NotBoundException;
import javax.rmi.*;
import java.util.Vector;
import javax.naming.NamingException;
import javax.naming.InitialContext;
import javax.naming.Context;
public class RegistryClient {
public static void main( String args[] ) {
Context ic;
Object objref;
RegistryIntf hi;
try {
ic = new InitialContext();
// STEP 1: Get the Object reference from the Name Service
// using JNDI call.
objref = ic.lookup("Registry");
System.out.println("Client: Obtained a ref. to Registry.");
// STEP 2: Narrow the object reference to the concrete type and
// invoke the method.
hi = (RegistryIntf) PortableRemoteObject.narrow(
objref, RegistryIntf.class);
hi.sayHello();
} catch( Exception e ) {
System.err.println( "Exception " + e + "Caught" );
e.printStackTrace( );
return;
}
}
}
==================================================
NOw as staed in the Tutorial is compiled all the classes using javac ..
Now I generated the syubs using rmic -iiop
Here first problem came , It didn'nt generated the Tie class , but in the example it is written that the Tie classes will be generrated.
Now I started my orbd with the given option
start orbd -ORBInitialPort 1050
now when i run my Server Program (Registry.java) the following exception is thrown .
java.rmi.StubNotFoundException: Stub class not found: Registry_Stub; nested exce
ption is:
java.lang.ClassNotFoundException: Registry_Stub
java.lang.ClassNotFoundException: Registry_Stub
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.rmi.server.RemoteProxy.loadClassFromClass(Unknown Source)
at sun.rmi.server.RemoteProxy.getStub(Unknown Source)
at sun.rmi.server.RemoteProxy.getStub(Unknown Source)
at sun.rmi.server.UnicastServerRef.setSkeleton(Unknown Source)
at sun.rmi.server.UnicastServerRef.exportObject(Unknown Source)
at sun.rmi.server.UnicastServerRef.exportObject(Unknown Source)
at java.rmi.server.UnicastRemoteObject.exportObject(Unknown Source)
at java.rmi.server.UnicastRemoteObject.exportObject(Unknown Source)
at java.rmi.server.UnicastRemoteObject.exportObject(Unknown Source)
at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.exportObject
(Unknown Source)
at javax.rmi.PortableRemoteObject.exportObject(Unknown Source)
at javax.rmi.PortableRemoteObject.<init>(Unknown Source)
at Registry.<init>(Registry.java:10)
at Registry.main(Registry.java:24)
Now I made the stub by rmic Registry command : (Going against what is given in the Tutorial)
Now I again run the same Registry Program , it is throwing tthe below error:
java.lang.IllegalArgumentException: Only instances of org.omg.CORBA.Object can
e bound
at com.sun.jndi.cosnaming.CNCtx.callBindOrRebind(Unknown Source)
at com.sun.jndi.cosnaming.CNCtx.rebind(Unknown Source)
at com.sun.jndi.cosnaming.CNCtx.rebind(Unknown Source)
at javax.naming.InitialContext.rebind(Unknown Source)
at Registry.main(Registry.java:26)
So can any one help me out to explain why above error's are being thrown : and what is the solution
TIA