Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problem accesing EJBs over IIOP

0 views
Skip to first unread message

Sri

unread,
Jan 12, 2004, 11:22:29 AM1/12/04
to

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 ?

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)

Andy Piper

unread,
Jan 21, 2004, 1:12:00 PM1/21/04
to
"Sri" <svlakh...@yahoo.com> writes:

> 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

0 new messages