This content has been marked as final.
Show 2 replies
-
1. Re: invoking remote session bean NotContextException
srki Nov 3, 2006 1:33 PM (in response to srki)I still didn't solve my problem but I tried to deploy it on my local machine and see I could somehow find what the issue is when deploying it on a remote machine.
Initially deploying it on my local machine everything worked fine
However when I add the following line I see that code breaks.String host = "jnp://localhost:1099"; props.setProperty(Context.PROVIDER_URL, host); I started getting the following exception 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.narrow(PortableRemoteObject.java:229) 2006-11-03 10:17:18,319 ERROR [STDERR] at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.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. I am not sure how to see what is the wrapper class for the object since the call to object.getClass().getName() prints something like this $Proxy184
This is my code again:
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 -
2. Re: invoking remote session bean NotContextException
srki Nov 3, 2006 7:37 PM (in response to srki)Through reflection on object I see that it is the correct HomeRemote interface and the right method, but I still can not figure out what is the difference of specifying Context.PROVIDER_URL with jnp://localhost:1099