[jboss-user] [Beginners Corner] - ClassCastException with PortableRemoteObject.narrow call
srki
do-not-reply at jboss.com
Fri Nov 3 19:40:35 EST 2006
I want to call an ejb component located on a different machine and I can not get it to work. So I tried to deploy it under local copy of jboss and try to invoke it. I was able to call it. So i tried adding Context.PROVIDER_URL with my localhost set. I always get the ClassCastException. If I am remove the line from below everything works fine.
String host = "jnp://localhost:1099";
props.setProperty(Context.PROVIDER_URL, host);
2006-11-03 10:17:18,319 ERROR [STDERR] java.lang.ClassCastException
2006-11-03 10:17:18,319 ERROR [STDERR] at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narr
ow(PortableRemoteObject.java:229)
2006-11-03 10:17:18,319 ERROR [STDERR] at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObjec
t.java:137)
As soon as I uncomment that props.setProperty(Context.PROVIDER_URL, host);
line everything works fine.
I have seen this type of exception before when I tried invoking the ejb on a different computer as well. When I inspect the object with reflection I see that it found the right remote home interface.
This is my code:
Properties props = new Properties();
props.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.jboss.security.jndi.JndiLoginInitialContextFactory");
props.setProperty(Context.SECURITY_PRINCIPAL, "admin");
props.setProperty(Context.SECURITY_CREDENTIALS, "admin");
props.put(javax.naming.Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
String host = "jnp://localhost:1099";
props.setProperty(Context.PROVIDER_URL, host);
ctx = new InitialContext( props );
Object object = ctx.lookup( "ejb/com/blah/Manager" );
ManagerRemoteHome home = (ManagerRemoteHome)PortableRemoteObject.narrow ( object, ManagerRemoteHome.class);
ManagerRemote manager = home.create();
Thanks
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3983151#3983151
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3983151
More information about the jboss-user
mailing list