This content has been marked as final.
Show 6 replies
-
1. Re: javax.naming.NotContextException
jaikiran Jun 6, 2007 12:33 PM (in response to psyllogism)<jndi-name>MetaAgentImpl</jndi-name>
So your lookup should be:Object ref = jndiContext.lookup("MetaAgentImpl");
-
2. Re: javax.naming.NotContextException
psyllogism Jun 6, 2007 1:06 PM (in response to psyllogism)Okay. Then on this line:
m_metaAgent = (MetaAgent) PortableRemoteObject.narrow(ref, MetaAgent.class);
I get the exception:java.lang.ClassCastException at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(Unknown Source) at javax.rmi.PortableRemoteObject.narrow(Unknown Source) ...
The jndiContext.lookup(...) method returned a "MetaAgentImplStatefulProxyFactory" object, which isn't anything in my project!
So I still need help. Thanks. -
3. Re: javax.naming.NotContextException
jaikiran Jun 6, 2007 2:22 PM (in response to psyllogism)Which version of EJB are you using? Is it EJB2 or EJB3. Since you posted this in EJB3 forum, i guessed it was EJB3, but i am not sure going by your question.
Also, could you post the contents of your ejb-jar.xml (if you have one) and the code where you are doing this lookup and narrow -
4. Re: javax.naming.NotContextException
psyllogism Jun 6, 2007 2:38 PM (in response to psyllogism)Yes, I am using EJB 3.0. I currently do not have an ejb-jar.xml file. I have not developed with EJBs before but I thought that EJB 3.0 does not need one?
The lookup code:// Lookup the meta-agent Properties p = new Properties(); p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); p.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces"); p.put(Context.PROVIDER_URL, "jnp://" + m_hostName + ":" + m_serverPortNumber); Context jndiContext = new InitialContext(p); Object ref = jndiContext.lookup("MetaAgentImpl"); m_metaAgent = (MetaAgent) PortableRemoteObject.narrow(ref, MetaAgent.class);
The MetaAgent interface:@Remote public interface MetaAgent { ... }
The MetaAgent implementation:@Stateful public class MetaAgentImpl extends AbstractSessionAgent implements MetaAgent, Serializable { ... }
Thanks for looking! -
5. Re: javax.naming.NotContextException
jaikiran Jun 6, 2007 2:47 PM (in response to psyllogism)Yes, I am using EJB 3.0. I currently do not have an ejb-jar.xml file. I have not developed with EJBs before but I thought that EJB 3.0 does not need one?
Yes, that's right. I just wanted to confirm you were not using one.m_metaAgent = (MetaAgent) PortableRemoteObject.narrow(ref, MetaAgent.class);
In EJB3, you no longer need the PortableRemoteObject.narrow. You can directly cast the returned object to the remote interface:MetaAgent metaAgent = (MetaAgent) jndiContext.lookup("MetaAgentImpl");
-
6. Re: javax.naming.NotContextException
psyllogism Jun 6, 2007 3:23 PM (in response to psyllogism)I solved it!
I needed to add:
jboss-ejb3-client.jar
jboss-aspect-jdk50-client.jar
jboss-aop-jdk50-client.jar
to my build path.
Now I get to move on to my next error(s), which does not seem to be JBoss/EJB3 related.
Thanks for being patient with me!