1 Reply Latest reply on Jan 6, 2006 7:23 AM by marek chowaniok

    "env not bound" with EJB calling another EJB

    Michael Suiter Newbie

      i have this problem when one EJB calls another EJB using the local interface. strange thing is i have another EJB that i access from other EJBs and it works. i've checked my xdoclet tags, deployment descriptors, ran the code in debug, and i can't figure out why one works and the other doesn't.

      i'm using the COMP_NAME (java:comp/env/ejb/RulesEnginePvt_EJB) in xdoclet. the error occurs in the InitialContext.lookup(name). if i change the lookup to JNDI_NAME, it works fine. i use COMP_NAME for looking up my other EJB locally and it works. i believe i've read that COMP_NAME is the preferred method. here is my error:

      com.workpoint.common.exception.ScriptEngineException: Exception caught when invoking the Business Rules Engine.; nested exception is:
       javax.naming.NameNotFoundException: env not bound
      
      javax.naming.NameNotFoundException: env not bound
      
       at org.jnp.server.NamingServer.getBinding(NamingServer.java:491)
      
       at org.jnp.server.NamingServer.getBinding(NamingServer.java:499)
      
       at org.jnp.server.NamingServer.getObject(NamingServer.java:505)
      
       at org.jnp.server.NamingServer.lookup(NamingServer.java:249)
      
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:610)
      
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:701)
      
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
      
       at javax.naming.InitialContext.lookup(InitialContext.java:347)
      
       at com.workpoint.server.ejb.RulesEnginePvt_EJBUtil.lookupHome(RulesEnginePvt_EJBUtil.java:25)
      
       at com.workpoint.server.ejb.RulesEnginePvt_EJBUtil.getLocalHome(RulesEnginePvt_EJBUtil.java:67)
      
       at com.workpoint.server.script.StatementEngineBRE.invokeRulesEngine(StatementEngineBRE.java:293)
      
       at com.workpoint.server.script.StatementEngineBRE.execute(StatementEngineBRE.java:91)
      
       at com.workpoint.server.script.ScriptEngine.executeStatement(ScriptEngine.java:624)
      
       at com.workpoint.server.script.ScriptEngine.execute(ScriptEngine.java:510)
      
       at com.workpoint.server.script.ScriptEngine.execute(ScriptEngine.java:481)
      
       at com.workpoint.server.job.Job.getTransitionResult(Job.java:825)
      
       at com.workpoint.server.job.Job.evaluateTransition(Job.java:881)
      
       at com.workpoint.server.job.Job.evaluateDownstreamTransitions(Job.java:989)
      
       at com.workpoint.server.job.Job.evaluateNode(Job.java:1692)
      
       at com.workpoint.server.job.Job.evaluate(Job.java:1865)
      
       at com.workpoint.server.job.Job.evaluate(Job.java:1776)
      
       at com.workpoint.server.ejb.JobUpdatePvtBean.evaluateData(JobUpdatePvtBean.java:1057)
      
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      
       at java.lang.reflect.Method.invoke(Method.java:324)
      
       at org.jboss.invocation.Invocation.performCall(Invocation.java:345)
      
       at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:214)
      
       at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
      
       at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:130)
      
       at org.jboss.webservice.server.ServiceEndpointInterceptor.invoke(ServiceEndpointInterceptor.java:51)
      
       at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:48)
      
       at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:105)
      
       at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:335)
      
       at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:166)
      
       at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:139)
      
       at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
      
       at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
      
       at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:624)
      
       at org.jboss.ejb.Container.invoke(Container.java:873)
      
       at sun.reflect.GeneratedMethodAccessor86.invoke(Unknown Source)
      
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      
       at java.lang.reflect.Method.invoke(Method.java:324)
      
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
      
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
      
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
      
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
      
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
      
       at org.jboss.invocation.jrmp.server.JRMPInvoker$MBeanServerAction.invoke(JRMPInvoker.java:805)
      
       at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:406)
      
       at sun.reflect.GeneratedMethodAccessor99.invoke(Unknown Source)
      
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      
       at java.lang.reflect.Method.invoke(Method.java:324)
      
       at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
      
       at sun.rmi.transport.Transport$1.run(Transport.java:148)
      
       at java.security.AccessController.doPrivileged(Native Method)
      
       at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
      
       at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
      
       at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      
       at java.lang.Thread.run(Thread.java:534)
      
      


      here is part of my ejb-jar.xml. JobUpdatePvt is trying to call RulesEnginePvt.

       <session >
       <description><![CDATA[This class contains the implementation of the methods defined in the JobUpdatePvt interface.]]></description>
       <display-name>JobUpdatePvt</display-name>
      
       <ejb-name>JobUpdatePvt_EJB</ejb-name>
      
       <home>com.workpoint.server.ejb.JobUpdatePvtHome</home>
       <remote>com.workpoint.server.ejb.JobUpdatePvt</remote>
       <local-home>com.workpoint.server.ejb.JobUpdatePvtLocalHome</local-home>
       <local>com.workpoint.server.ejb.JobUpdatePvtLocal</local>
       <ejb-class>com.workpoint.server.ejb.JobUpdatePvt_EJBSession</ejb-class>
       <session-type>Stateless</session-type>
       <transaction-type>Container</transaction-type>
      
       <ejb-local-ref >
       <ejb-ref-name>ejb/RulesEnginePvt_EJBLocal</ejb-ref-name>
       <ejb-ref-type>Session</ejb-ref-type>
       <local-home>com.workpoint.server.ejb.RulesEnginePvtLocalHome</local-home>
       <local>com.workpoint.server.ejb.RulesEnginePvtLocal</local>
       <ejb-link>RulesEnginePvt_EJB</ejb-link>
       </ejb-local-ref>
       <ejb-local-ref >
       <ejb-ref-name>ejb/UniqueIDUpdatePvt_EJBLocal</ejb-ref-name>
       <ejb-ref-type>Session</ejb-ref-type>
       <local-home>com.workpoint.server.ejb.UniqueIDUpdatePvtLocalHome</local-home>
       <local>com.workpoint.server.ejb.UniqueIDUpdatePvtLocal</local>
       <ejb-link>UniqueIDUpdatePvt_EJB</ejb-link>
       </ejb-local-ref>
      
       <resource-ref >
       <res-ref-name>jdbc/WPDS</res-ref-name>
       <res-type>javax.sql.DataSource</res-type>
       <res-auth>Container</res-auth>
       </resource-ref>
       <resource-ref >
       <res-ref-name>jdbc/WPDS2</res-ref-name>
       <res-type>javax.sql.DataSource</res-type>
       <res-auth>Container</res-auth>
       </resource-ref>
       <resource-ref >
       <res-ref-name>jdbc/WPDS3</res-ref-name>
       <res-type>javax.sql.DataSource</res-type>
       <res-auth>Container</res-auth>
       </resource-ref>
      
       </session>
      
      ...
      
       <session >
       <description><![CDATA[This class contains the implementation of the methods defined in the RulesEnginePvt interface.]]></description>
       <display-name>RulesEnginePvt</display-name>
      
       <ejb-name>RulesEnginePvt_EJB</ejb-name>
      
       <home>com.workpoint.server.ejb.RulesEnginePvtHome</home>
       <remote>com.workpoint.server.ejb.RulesEnginePvt</remote>
       <local-home>com.workpoint.server.ejb.RulesEnginePvtLocalHome</local-home>
       <local>com.workpoint.server.ejb.RulesEnginePvtLocal</local>
       <ejb-class>com.workpoint.server.ejb.RulesEnginePvt_EJBSession</ejb-class>
       <session-type>Stateless</session-type>
       <transaction-type>Container</transaction-type>
      
       <resource-ref >
       <res-ref-name>jdbc/WPDS</res-ref-name>
       <res-type>javax.sql.DataSource</res-type>
       <res-auth>Container</res-auth>
       </resource-ref>
       <resource-ref >
       <res-ref-name>jdbc/WPDS2</res-ref-name>
       <res-type>javax.sql.DataSource</res-type>
       <res-auth>Container</res-auth>
       </resource-ref>
       <resource-ref >
       <res-ref-name>jdbc/WPDS3</res-ref-name>
       <res-type>javax.sql.DataSource</res-type>
       <res-auth>Container</res-auth>
       </resource-ref>
      
       </session>
      
      


      here is part of my jboss.xml

       <session>
       <ejb-name>JobUpdatePvt_EJB</ejb-name>
       <jndi-name>JobUpdatePvt_EJB</jndi-name>
       <local-jndi-name>JobUpdatePvt_EJBLocal</local-jndi-name>
      
       <resource-ref>
       <res-ref-name>jdbc/WPDS</res-ref-name>
       <jndi-name>jdbc/WPDS</jndi-name>
       </resource-ref>
       <resource-ref>
       <res-ref-name>jdbc/WPDS2</res-ref-name>
       <jndi-name>jdbc/WPDS2</jndi-name>
       </resource-ref>
       <resource-ref>
       <res-ref-name>jdbc/WPDS3</res-ref-name>
       <jndi-name>jdbc/WPDS3</jndi-name>
       </resource-ref>
      
       <method-attributes>
       </method-attributes>
       </session>
      ...
       <session>
       <ejb-name>RulesEnginePvt_EJB</ejb-name>
       <jndi-name>RulesEnginePvt_EJB</jndi-name>
       <local-jndi-name>RulesEnginePvt_EJBLocal</local-jndi-name>
      
       <resource-ref>
       <res-ref-name>jdbc/WPDS</res-ref-name>
       <jndi-name>jdbc/WPDS</jndi-name>
       </resource-ref>
       <resource-ref>
       <res-ref-name>jdbc/WPDS2</res-ref-name>
       <jndi-name>jdbc/WPDS2</jndi-name>
       </resource-ref>
       <resource-ref>
       <res-ref-name>jdbc/WPDS3</res-ref-name>
       <jndi-name>jdbc/WPDS3</jndi-name>
       </resource-ref>
      
       <method-attributes>
       </method-attributes>
       </session>
      


      we were seeing the error on jboss 3.2.2 and xdoclet 1.2. i have since switched to jboss 4.0.2 and xdoclet 1.2.3 and still the same error. i have even debugged the code and everything looks like it should work.

      any ideas?

      thanks!