This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
// 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();
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
Double check how you're generating the stub and tie with the rmic command... I was able to take the code you posted and generate both the stub and tie from it using "rmic -classpath . -iiop Registry".
-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Ankit Singhal
Greenhorn
Joined: Aug 13, 2004
Posts: 4
posted
0
Hi
I have run the rmic -iiop on the RegistryIntf not Registry class and one more thing I added following lines
Context rootContext=(Context)initialNamingContext.lookup(""); System.out.println("The Look up suceeded");
to see whether it is able to look up the root context or not. I saw that it is suceeded in finding the root context and print the message also , but again failed to rebind the object .thrwing following exception
D:\OMC-RAN\Hands On Coding\RMI -IIOP>java -classpath . -Djava.naming.factory.ini tial=com.sun.jndi.cosnaming.CNCtxFactory -Djava.naming.provider.url=iiop://local host:1050 Registry Inside Constructor The Look up suceeded java.lang.IllegalArgumentException: Only instances of org.omg.CORBA.Object can b 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:30)
I was able to get the server to bind correctly using the same command... make sure that all the class files needed (including the tie and the stub) are in the current directory. Make sure the stub isn't the one that you initially built just using rmic (with no -iiop).
As long as Registry still extends PortableRemoteObject and implements RegistryIntf, as long as RegistryIntf still extends Remote, and as long as the tie and the stub are getting built correctly using rmic -iiop, there shouldn't be a problem.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: Problem Executing RMI-IIOP Example : Provided by Sun