Thanks in advance!
-Sri
CODE:
import java.util.Properties;
import javax.rmi.PortableRemoteObject;
import com.slv.server.biztier.ws.StringMessageHome;
import com.slv.server.biztier.ws.StringMessage;
import javax.naming.*;
public class IIOPEjb {
public static void main(String[] args) {
try{
args = new String[3];
args[0] = "com.sun.jndi.cosnaming.CNCtxFactory";
args[1] = "iiop://192.168.1.157:7001";
args[2] = "com.slv.server.biztier.ws.StringMessageHome";
Properties prop = new Properties();
prop.setProperty("java.naming.factory.initial",args[0]);
prop.setProperty("java.naming.provider.url",args[1]);
InitialContext ic = new InitialContext(prop);
Object obj = ic.lookup(args[2]);
if (obj != null) {
StringMessageHome home
= (StringMessageHome)
PortableRemoteObject.narrow(obj,StringMessageHome.class);
StringMessage main = home.create();
String msg = main.getServerMessage();
System.out.println("Server msg: " + msg);
}
}catch(Exception e){
System.out.println(e);
e.printStackTrace();
}
}
}
EXCEPTION:
java.lang.ClassCastException
java.lang.ClassCastException
at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:293)
at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:134)
at jnditest.IIOPEjb.main(IIOPEjb.java:23)
> I am trying to access an EJB over IIOP, using the com.sun.jndi.cosnaming.CNCtxFactory
> as the initial context factory. The code and the exception I am getting are posted
> below. Can anyone clarify what I am doing wrong ?
It can't download stubs. You need to specify something like (this is all on edocs):
-Djava.security.manager -Djava.security.policy==java.policy
on the command line where java.policy grants everything. Or put the
stubs in your client classpath.
andy