6 Replies Latest reply on Oct 20, 2008 11:11 PM by steven yong

    lookup datasource from ejb3 sessionbean (jboss 4.2.3)

    steven yong Newbie

      I have a requirement to setup 2 instances of same application (one for live and one for testing) running on jboss 4.2.3.GA. I don't want to run multiple instances of Jboss server since it requires changing all the listening ports, so i decided to move the "hard-coded" actual jndi name from my ejb3 sessionbean (I'm using @javax.annotation.Resource injection currently), i tried and failed to lookup the datasource using:

      (in sessionbean)
      Context ic = new InitialContext();
      ds = (DataSource) ic.lookup("java:comp/env/jdbc/ds_name");
      (ejb-jar.xml)
      <enterprise-beans>

      <ejb-name>AdmResourceFacade</ejb-name>
      com.tims.ac.service.AdmResourceFacade <ejb-class>com.tims.ac.service.AdmResourceFacadeImpl</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>
      <resource-ref>
      <res-ref-name>jdbc/ds_name</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>

      </enterprise-beans>
      (in jboss.xml)
      <enterprise-beans>

      <ejb-name>AdmResourceFacade</ejb-name>
      <resource-ref>
      <res-ref-name>jdbc/ds_name</res-ref-name>
      <jndi-name>java:/actual_ds_name</jndi-name>
      </resource-ref>

      </enterprise-beans>

      i get javax.naming.NameNotFoundException: jdbc not bound when looking up the datasource, please help.

        • 1. Re: lookup datasource from ejb3 sessionbean (jboss 4.2.3)
          jaikiran pai Master

          The configurations and the code that you have posted looks correct. But is this the exact code that you are using? Especially are you doing the lookup in the com.tims.ac.service.AdmResourceFacadeImpl bean? Also, please post the entire exception stacktrace and the output of jnditree. You can view the jndi tree contents by following the steps mentioned at http://www.jboss.org/community/docs/DOC-9583

          • 2. Re: lookup datasource from ejb3 sessionbean (jboss 4.2.3)
            steven yong Newbie

            yes that's exacty the piece of code that i tried. i think something's wrong with my configuration, i can't even lookup environment entry:

            (ejb-jar.xml)
            <env-entry>
            the ds jndi
            <env-entry-name>ds_jndi</env-entry-name>
            <env-entry-type>java.lang.String</env-entry-type>
            <env-entry-value>java:/tims</env-entry-value>
            </env-entry>

            (in code)
            InitialContext ic = new InitialContext();
            Context envCtx = (Context) ic.lookup("java:comp/env");
            String name = (String) envCtx.lookup("ds_jndi");
            System.out.println(" ** jndi="+name);

            this cause error with exception "name ds_jndi not found". any clue what might be the problem? ejb3 on jboss 4.2.3? my configuration?

            • 3. Re: lookup datasource from ejb3 sessionbean (jboss 4.2.3)
              jaikiran pai Master

               

              "woongiap" wrote:
              any clue what might be the problem?


              You will have to provide us additional details like:

              "jaikiran" wrote:
              Also, please post the entire exception stacktrace and the output of jnditree. You can view the jndi tree contents by following the steps mentioned at http://www.jboss.org/community/docs/DOC-9583


              • 4. Re: lookup datasource from ejb3 sessionbean (jboss 4.2.3)
                steven yong Newbie

                 

                "jaikiran" wrote:
                Also, please post the entire exception stacktrace and the output of jnditree.

                exception stacktrace:

                Caused by: javax.ejb.EJBException: java.lang.RuntimeException: javax.naming.NameNotFoundException: ds_jndi not bound
                at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:63)
                at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
                at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
                at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
                at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
                at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
                at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
                at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
                at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
                at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:240)
                at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:210)
                at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:84)
                at $Proxy103.updateResource(Unknown Source)
                at com.tims.ac.web.beans.ResourcePage.save(ResourcePage.java:58)
                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:597)
                at org.apache.el.parser.AstValue.invoke(AstValue.java:131)
                at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
                at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
                at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
                ... 38 more
                Caused by: java.lang.RuntimeException: javax.naming.NameNotFoundException: ds_jndi not bound
                at com.tims.ac.service.AdmResourceFacadeImpl.getDataSource(AdmResourceFacadeImpl.java:374)
                at com.tims.ac.service.AdmResourceFacadeImpl.updateResource(AdmResourceFacadeImpl.java:324)
                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:597)
                at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
                at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
                at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
                at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
                at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
                at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
                ... 64 more
                Caused by: javax.naming.NameNotFoundException: ds_jndi not bound
                at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
                at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
                at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
                at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
                at org.jnp.server.NamingServer.lookup(NamingServer.java:270)
                at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:667)
                at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
                at com.tims.ac.service.AdmResourceFacadeImpl.getDataSource(AdmResourceFacadeImpl.java:367)
                ... 78 more
                20:45:05,945 ERROR [[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception
                javax.naming.NameNotFoundException: ds_jndi not bound
                at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
                at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
                at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
                at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
                at org.jnp.server.NamingServer.lookup(NamingServer.java:270)
                at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:667)
                at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
                at com.tims.ac.service.AdmResourceFacadeImpl.getDataSource(AdmResourceFacadeImpl.java:367)
                at com.tims.ac.service.AdmResourceFacadeImpl.updateResource(AdmResourceFacadeImpl.java:324)
                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:597)
                at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
                at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
                at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
                at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
                at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
                at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
                at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
                at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
                at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
                at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
                at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
                at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
                at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
                at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:240)
                at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:210)
                at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:84)
                at $Proxy103.updateResource(Unknown Source)
                at com.tims.ac.web.beans.ResourcePage.save(ResourcePage.java:58)
                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:597)
                at org.apache.el.parser.AstValue.invoke(AstValue.java:131)
                at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
                at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
                at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
                at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
                at javax.faces.component.UICommand.broadcast(UICommand.java:387)
                at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:321)
                at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:296)
                at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:253)
                at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:466)
                at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
                at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
                at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
                at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:177)
                at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:267)
                at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:380)
                at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:507)
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
                at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
                at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:524)
                at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
                at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
                at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
                at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
                at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
                at java.lang.Thread.run(Thread.java:619)

                Output of jnditree:
                java:comp namespace of the jmx-console.war application:

                +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
                +- env (class: org.jnp.interfaces.NamingContext)
                | +- security (class: org.jnp.interfaces.NamingContext)
                | | +- realmMapping[link -> java:/jaas/other] (class: javax.naming.LinkRef)
                | | +- subject[link -> java:/jaas/other/subject] (class: javax.naming.LinkRef)
                | | +- securityMgr[link -> java:/jaas/other] (class: javax.naming.LinkRef)
                | | +- security-domain[link -> java:/jaas/other] (class: javax.naming.LinkRef)


                java:comp namespace of the http-invoker.sar/invoker.war application:

                +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
                +- env (class: org.jnp.interfaces.NamingContext)
                | +- security (class: org.jnp.interfaces.NamingContext)
                | | +- realmMapping[link -> java:/jaas/jmx-console] (class: javax.naming.LinkRef)
                | | +- subject[link -> java:/jaas/jmx-console/subject] (class: javax.naming.LinkRef)
                | | +- securityMgr[link -> java:/jaas/jmx-console] (class: javax.naming.LinkRef)
                | | +- security-domain[link -> java:/jaas/jmx-console] (class: javax.naming.LinkRef)


                java:comp namespace of the tims-ac.ear/tims-ac.war application:

                +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
                +- env (class: org.jnp.interfaces.NamingContext)
                | +- ejb (class: org.jnp.interfaces.NamingContext)
                | | +- SecurityFacade[link -> tims-ac/AdmSecurityFacadeImpl/local] (class: javax.naming.LinkRef)
                | | +- DocumentManager[link -> tims-ac/DocumentManagerImpl/local] (class: javax.naming.LinkRef)
                | | +- Configurator[link -> tims-ac/ConfiguratorImpl/local] (class: javax.naming.LinkRef)
                | | +- ComponentManager[link -> tims-ac/ComponentManagerImpl/local] (class: javax.naming.LinkRef)
                | | +- ResourceFacade[link -> tims-ac/AdmResourceFacadeImpl/local] (class: javax.naming.LinkRef)
                | | +- BpFacade[link -> tims-ac/AdmBpFacadeImpl/local] (class: javax.naming.LinkRef)
                | | +- ProfileFacade[link -> tims-ac/AdmProfileFacadeImpl/local] (class: javax.naming.LinkRef)
                | +- security (class: org.jnp.interfaces.NamingContext)
                | | +- realmMapping[link -> java:/jaas/tims] (class: javax.naming.LinkRef)
                | | +- subject[link -> java:/jaas/tims/subject] (class: javax.naming.LinkRef)
                | | +- securityMgr[link -> java:/jaas/tims] (class: javax.naming.LinkRef)
                | | +- security-domain[link -> java:/jaas/tims] (class: javax.naming.LinkRef)


                java:comp namespace of the jbossmq-httpil.sar/jbossmq-httpil.war application:

                +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
                +- env (class: org.jnp.interfaces.NamingContext)
                | +- security (class: org.jnp.interfaces.NamingContext)
                | | +- realmMapping[link -> java:/jaas/jbossmq] (class: javax.naming.LinkRef)
                | | +- subject[link -> java:/jaas/jbossmq/subject] (class: javax.naming.LinkRef)
                | | +- securityMgr[link -> java:/jaas/jbossmq] (class: javax.naming.LinkRef)
                | | +- security-domain[link -> java:/jaas/jbossmq] (class: javax.naming.LinkRef)


                java:comp namespace of the console-mgr.sar/web-console.war application:

                +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
                +- env (class: org.jnp.interfaces.NamingContext)
                | +- security (class: org.jnp.interfaces.NamingContext)
                | | +- realmMapping[link -> java:/jaas/other] (class: javax.naming.LinkRef)
                | | +- subject[link -> java:/jaas/other/subject] (class: javax.naming.LinkRef)
                | | +- securityMgr[link -> java:/jaas/other] (class: javax.naming.LinkRef)
                | | +- security-domain[link -> java:/jaas/other] (class: javax.naming.LinkRef)


                java:comp namespace of the jboss-web.deployer/ROOT.war application:

                +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
                +- env (class: org.jnp.interfaces.NamingContext)
                | +- security (class: org.jnp.interfaces.NamingContext)
                | | +- realmMapping[link -> java:/jaas/other] (class: javax.naming.LinkRef)
                | | +- subject[link -> java:/jaas/other/subject] (class: javax.naming.LinkRef)
                | | +- securityMgr[link -> java:/jaas/other] (class: javax.naming.LinkRef)
                | | +- security-domain[link -> java:/jaas/other] (class: javax.naming.LinkRef)


                java:comp namespace of the jbossws.sar/jbossws-context.war application:

                +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
                +- env (class: org.jnp.interfaces.NamingContext)
                | +- security (class: org.jnp.interfaces.NamingContext)
                | | +- realmMapping[link -> java:/jaas/other] (class: javax.naming.LinkRef)
                | | +- subject[link -> java:/jaas/other/subject] (class: javax.naming.LinkRef)
                | | +- securityMgr[link -> java:/jaas/other] (class: javax.naming.LinkRef)
                | | +- security-domain[link -> java:/jaas/other] (class: javax.naming.LinkRef)


                java: Namespace

                +- tims (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
                +- jaas (class: javax.naming.Context)
                | +- HsqlDbRealm (class: org.jboss.security.plugins.SecurityDomainContext)
                | +- jbossmq (class: org.jboss.security.plugins.SecurityDomainContext)
                | +- tims (class: org.jboss.security.plugins.SecurityDomainContext)
                | +- JmsXARealm (class: org.jboss.security.plugins.SecurityDomainContext)
                +- TransactionPropagationContextImporter (class: com.arjuna.ats.internal.jbossatx.jta.PropagationContextManager)
                +- comp.ejb3 (class: javax.naming.Context)
                | NonContext: null
                +- JmsXA (class: org.jboss.resource.adapter.jms.JmsConnectionFactoryImpl)
                +- DefaultDS (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
                +- StdJMSPool (class: org.jboss.jms.asf.StdServerSessionPoolFactory)
                +- TransactionManager (class: com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate)
                +- TransactionPropagationContextExporter (class: com.arjuna.ats.internal.jbossatx.jta.PropagationContextManager)
                +- ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
                +- tims-mssql (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
                +- DefaultJMSProvider (class: org.jboss.jms.jndi.JNDIProviderAdapter)
                +- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
                +- Mail (class: javax.mail.Session)
                +- comp.original (class: javax.namingMain.Context)
                +- timedCacheFactory (class: javax.naming.Context)
                Failed to lookup: timedCacheFactory, errmsg=org.jboss.util.TimedCachePolicy cannot be cast to javax.naming.NamingEnumeration
                +- SecurityProxyFactory (class: org.jboss.security.SubjectSecurityProxyFactory)
                +- comp (class: javax.naming.Context)
                +- jcr (class: org.jnp.interfaces.NamingContext)
                | +- dev (class: org.apache.jackrabbit.jca.JCARepositoryHandle)
                | +- local (class: org.apache.jackrabbit.jca.JCARepositoryHandle)


                Global JNDI Namespace

                +- TopicConnectionFactory (class: org.jboss.naming.LinkRefPair)
                +- jmx (class: org.jnp.interfaces.NamingContext)
                | +- invoker (class: org.jnp.interfaces.NamingContext)
                | | +- RMIAdaptor (proxy: $Proxy47 implements interface org.jboss.jmx.adaptor.rmi.RMIAdaptor,interface org.jboss.jmx.adaptor.rmi.RMIAdaptorExt)
                | +- rmi (class: org.jnp.interfaces.NamingContext)
                | | +- RMIAdaptor[link -> jmx/invoker/RMIAdaptor] (class: javax.naming.LinkRef)
                +- persistence.units:ear=tims-ac.ear,jar=tims-ac-ejb.jar,unitName=tims-ac-pu (class: org.hibernate.impl.SessionFactoryImpl)
                +- HTTPXAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
                +- ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
                +- UserTransactionSessionFactory (proxy: $Proxy15 implements interface org.jboss.tm.usertx.interfaces.UserTransactionSessionFactory)
                +- HTTPConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
                +- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
                +- TransactionSynchronizationRegistry (class: com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple)
                +- UserTransaction (class: org.jboss.tm.usertx.client.ClientUserTransaction)
                +- tims-ac (class: org.jnp.interfaces.NamingContext)
                | +- AdmProfileFacadeImpl (class: org.jnp.interfaces.NamingContext)
                | | +- local (proxy: $Proxy117 implements interface com.tims.ac.service.AdmProfileFacade,interface org.jboss.ejb3.JBossProxy)
                | +- AdmResourceFacadeImpl (class: org.jnp.interfaces.NamingContext)
                | | +- local (proxy: $Proxy103 implements interface com.tims.ac.service.AdmResourceFacade,interface org.jboss.ejb3.JBossProxy)
                | +- AdmBpFacadeImpl (class: org.jnp.interfaces.NamingContext)
                | | +- local (proxy: $Proxy85 implements interface com.tims.ac.service.AdmBpFacade,interface org.jboss.ejb3.JBossProxy)
                | +- AdmDocFacade (class: org.jnp.interfaces.NamingContext)
                | | +- local (proxy: $Proxy91 implements interface com.tims.ac.service.AdmDocFacadeLocal,interface org.jboss.ejb3.JBossProxy)
                | +- AdmConfigFacade (class: org.jnp.interfaces.NamingContext)
                | | +- local (proxy: $Proxy88 implements interface com.tims.ac.service.AdmConfigFacadeLocal,interface org.jboss.ejb3.JBossProxy)
                | +- ProfileManagerImpl (class: org.jnp.interfaces.NamingContext)
                | | +- local (proxy: $Proxy111 implements interface com.tims.ac.service.dm.ProfileManager,interface org.jboss.ejb3.JBossProxy)
                | +- ComponentManagerImpl (class: org.jnp.interfaces.NamingContext)
                | | +- local (proxy: $Proxy120 implements interface com.tims.server.service.ComponentManager,interface org.jboss.ejb3.JBossProxy)
                | +- DocumentManagerImpl (class: org.jnp.interfaces.NamingContext)
                | | +- local (proxy: $Proxy108 implements interface com.tims.ac.service.dm.DocumentManager,interface org.jboss.ejb3.JBossProxy)
                | +- ConfiguratorImpl (class: org.jnp.interfaces.NamingContext)
                | | +- local (proxy: $Proxy100 implements interface com.tims.ac.service.conf.Configurator,interface org.jboss.ejb3.JBossProxy)
                | +- AdmSecurityFacadeImpl (class: org.jnp.interfaces.NamingContext)
                | | +- local (proxy: $Proxy97 implements interface com.tims.ac.service.AdmSecurityFacade,interface org.jboss.ejb3.JBossProxy)
                | +- RepositoryManagerImpl (class: org.jnp.interfaces.NamingContext)
                | | +- local (proxy: $Proxy114 implements interface com.tims.ac.service.dm.RepositoryManager,interface org.jboss.ejb3.JBossProxy)
                | +- AdmResourceFacade (class: org.jnp.interfaces.NamingContext)
                | | +- local (proxy: $Proxy103 implements interface com.tims.ac.service.AdmResourceFacade,interface org.jboss.ejb3.JBossProxy)
                | +- AuditServiceImpl (class: org.jnp.interfaces.NamingContext)
                | | +- local (proxy: $Proxy94 implements interface com.tims.ac.service.audit.AuditService,interface org.jboss.ejb3.JBossProxy)
                +- UILXAConnectionFactory[link -> XAConnectionFactory] (class: javax.naming.LinkRef)
                +- UIL2XAConnectionFactory[link -> XAConnectionFactory] (class: javax.naming.LinkRef)
                +- queue (class: org.jnp.interfaces.NamingContext)
                | +- A (class: org.jboss.mq.SpyQueue)
                | +- testQueue (class: org.jboss.mq.SpyQueue)
                | +- ex (class: org.jboss.mq.SpyQueue)
                | +- DLQ (class: org.jboss.mq.SpyQueue)
                | +- D (class: org.jboss.mq.SpyQueue)
                | +- C (class: org.jboss.mq.SpyQueue)
                | +- B (class: org.jboss.mq.SpyQueue)
                +- topic (class: org.jnp.interfaces.NamingContext)
                | +- testDurableTopic (class: org.jboss.mq.SpyTopic)
                | +- testTopic (class: org.jboss.mq.SpyTopic)
                | +- securedTopic (class: org.jboss.mq.SpyTopic)
                +- console (class: org.jnp.interfaces.NamingContext)
                | +- PluginManager (proxy: $Proxy48 implements interface org.jboss.console.manager.PluginManagerMBean)
                +- UIL2ConnectionFactory[link -> ConnectionFactory] (class: javax.naming.LinkRef)
                +- HiLoKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.hilo.HiLoKeyGeneratorFactory)
                +- UILConnectionFactory[link -> ConnectionFactory] (class: javax.naming.LinkRef)
                +- QueueConnectionFactory (class: org.jboss.naming.LinkRefPair)
                +- UUIDKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.uuid.UUIDKeyGeneratorFactory)

                this error happens when i try to access the "jd_jndi" env-entry:
                (ejb-jar.xml)
                <env-entry>
                the ds jndi
                <env-entry-name>ds_jndi</env-entry-name>
                <env-entry-type>java.lang.String</env-entry-type>
                <env-entry-value>java:/tims</env-entry-value>
                </env-entry>


                • 5. Re: lookup datasource from ejb3 sessionbean (jboss 4.2.3)
                  jaikiran pai Master

                  Going by the jndi tree output, i think your ejb-jar.xml is not being read. Where have you placed this file? How is your application packaged? Is it a EAR file or a jar file? Post the output of:

                  jar -tf myapp.jar


                  where myapp.jar is the ejb jar file containing the ejb-jar.xml. Also please post the entire console logs. While posting the logs or code or xml content, remember to wrap it in a code block using the Code button in the message editor window and please hit the Preview button to make sure your post is correctly formatted. That way, its much more easier to read the post.



                  • 6. Re: lookup datasource from ejb3 sessionbean (jboss 4.2.3)
                    steven yong Newbie

                     

                    "jaikiran" wrote:
                    How is your application packaged?

                    I don't package it, i just deploy as a directory under /deploy, and there is the directory listing:
                     Directory of C:\jboss-4.2.3.GA\server\default\deploy\tims-ac.ear
                    
                    07/24/2008 04:19 PM <DIR> .
                    07/24/2008 04:19 PM <DIR> ..
                    08/18/2008 10:46 AM <DIR> META-INF
                    10/20/2008 05:31 PM <DIR> tims-ac-ejb.jar
                    10/15/2008 04:26 PM <DIR> tims-ac.war
                    
                     Directory of C:\jboss-4.2.3.GA\server\default\deploy\tims-ac.ear\META-INF
                    
                    08/18/2008 10:46 AM <DIR> .
                    08/18/2008 10:46 AM <DIR> ..
                    10/20/2008 04:47 PM 537 application.xml
                    04/12/2008 09:29 AM 55 jboss-app.xml
                    04/01/2008 04:58 PM 23 MANIFEST.MF
                    
                     Directory of C:\jboss-4.2.3.GA\server\default\deploy\tims-ac.ear\tims-ac-ejb.jar
                    
                    10/20/2008 05:31 PM <DIR> .
                    10/20/2008 05:31 PM <DIR> ..
                    10/20/2008 05:31 PM <DIR> com
                    10/20/2008 05:31 PM 118,726 commons-beanutils.jar
                    10/20/2008 05:31 PM 9,939 hibernate.cfg.xml
                    10/20/2008 08:44 PM <DIR> META-INF
                    
                     Directory of C:\jboss-4.2.3.GA\server\default\deploy\tims-ac.ear\tims-ac-ejb.jar\META-INF
                    
                    10/20/2008 08:44 PM <DIR> .
                    10/20/2008 08:44 PM <DIR> ..
                    10/20/2008 05:31 PM 58 context.xml
                    10/20/2008 08:44 PM 1,183 ejb-jar.xml
                    10/20/2008 05:31 PM 656 jboss.xml
                    10/20/2008 05:31 PM 23 MANIFEST.MF
                    10/20/2008 05:31 PM 705 persistence.xml
                    
                     Directory of C:\jboss-4.2.3.GA\server\default\deploy\tims-ac.ear\tims-ac.war
                    
                    10/15/2008 04:26 PM <DIR> .
                    10/15/2008 04:26 PM <DIR> ..
                    10/15/2008 04:26 PM <DIR> css
                    10/15/2008 04:26 PM 460 error.jsp
                    10/15/2008 04:26 PM 1,391 home.xhtml
                    10/15/2008 04:26 PM <DIR> images
                    10/15/2008 04:26 PM 170 index.jsp
                    10/15/2008 04:26 PM <DIR> js
                    10/15/2008 04:26 PM 5,065 logon.xhtml
                    10/15/2008 04:26 PM 2,330 main.htm
                    10/15/2008 04:26 PM <DIR> META-INF
                    10/15/2008 04:26 PM 3,335 test.jsp
                    10/15/2008 04:26 PM <DIR> view
                    10/15/2008 05:29 PM <DIR> WEB-INF
                    
                     Directory of C:\jboss-4.2.3.GA\server\default\deploy\tims-ac.ear\tims-ac.war\META-INF
                    
                    10/15/2008 04:26 PM <DIR> .
                    10/15/2008 04:26 PM <DIR> ..
                    10/15/2008 04:26 PM 62 context.xml
                    10/15/2008 04:26 PM 23 MANIFEST.MF
                    
                     Directory of C:\jboss-4.2.3.GA\server\default\deploy\tims-ac.ear\tims-ac.war\WEB-INF
                    
                    10/15/2008 05:29 PM <DIR> .
                    10/15/2008 05:29 PM <DIR> ..
                    10/15/2008 04:27 PM <DIR> classes
                    10/15/2008 04:26 PM 13,218 faces-config.xml
                    10/15/2008 04:26 PM 1,315 jboss-web.xml
                    10/15/2008 05:30 PM <DIR> layout
                    10/15/2008 05:29 PM <DIR> lib
                    10/15/2008 04:26 PM 7,496 LICENSE-datafile.txt
                    10/15/2008 04:26 PM 10,801 web.xml
                    10/15/2008 04:26 PM <DIR> wsdl
                    


                    thanks for pointing out my post's format problem.