Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0.0-beta-2
    • Fix Version/s: 1.0.0-beta-2
    • Component/s: None
    • Labels:
      None
    • Environment:
      Linux, JDK 6

      Description

      With previous versions of Tomcat 5 + OpenEJB I was able to lookup the TransactionManager as follows:

      Context context = new InitialContext();
      tm = context.lookup("java:comp/TransactionManager");

      A sample stack trace looks as follows:

      BasicException[1]
      Class = org.apache.naming.NamingContext
      Method = lookup
      Line = 803
      ExceptionClass = javax.naming.NameNotFoundException
      ExceptionDomain = DefaultDomain
      ExceptionCode = GENERIC
      Description = Name TransactionManager is not bound in this Context
      Timestamp = 2011-10-19T09:26:35.197Z
      Paramaters:
      0: explanation = Name TransactionManager is not bound in this Context
      StackTrace:
      at org.apache.naming.NamingContext.lookup(NamingContext.java:803)
      at org.apache.naming.NamingContext.lookup(NamingContext.java:145)
      at org.apache.naming.NamingContext.lookup(NamingContext.java:814)
      at org.apache.naming.NamingContext.lookup(NamingContext.java:159)
      at org.apache.naming.SelectorContext.lookup(SelectorContext.java:158)
      at javax.naming.InitialContext.lookup(InitialContext.java:392)
      at org.openmdx.kernel.naming.ComponentEnvironment.lookup(ComponentEnvironment.java:100)
      at org.openmdx.base.rest.spi.ConnectionAdapter.getTransactionManager(ConnectionAdapter.java:179)
      ...
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      at com.planetj.servlet.filter.compression.CompressingFilter.doFilter(CompressingFilter.java:217)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:185)
      at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:44)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:581)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:151)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:269)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
      at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      at java.lang.Thread.run(Thread.java:662)

      This does not seem to work any more with TomEE. Is there another way to do the lookup?

        Activity

        Hide
        Werner Froidevaux added a comment -

        Correction: with Tomcat 6 + OpenEJB I was able to do the lookup but not with TomEE.

        Show
        Werner Froidevaux added a comment - Correction: with Tomcat 6 + OpenEJB I was able to do the lookup but not with TomEE.
        Hide
        Romain Manni-Bucau added a comment -

        hi,

        it is weird indeed, can you just share a simple (even trivial) example please?

        Show
        Romain Manni-Bucau added a comment - hi, it is weird indeed, can you just share a simple (even trivial) example please?
        Hide
        Werner Froidevaux added a comment -

        You can put the code below in a JSP of any WAR and watch the console output.

        <%
        String jndiName = null;
        try

        { javax.naming.Context context = new javax.naming.InitialContext(); jndiName = "java:comp/UserTransaction"; Object obj = context.lookup(jndiName); System.out.println("lookup of " + jndiName + " OK"); jndiName = "java:comp/TransactionManager"; obj = context.lookup(jndiName); System.out.println("lookup of " + jndiName + " OK"); }

        catch(Exception e)

        { System.out.println("lookup of " + jndiName + " FAILED"); e.printStackTrace(); }

        %>

        E.g. I put it in ./webapps/openejb/index.jsp and get the following output:

        lookup of java:comp/UserTransaction OK
        lookup of java:comp/TransactionManager FAILED
        javax.naming.NameNotFoundException: Name TransactionManager is not bound in this Context
        at org.apache.naming.NamingContext.lookup(NamingContext.java:803)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:145)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:814)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:159)
        at org.apache.naming.SelectorContext.lookup(SelectorContext.java:158)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at org.apache.jsp.index_jsp._jspService(index_jsp.java:94)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:433)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:185)
        at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:44)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
        at org.apache.catalina.valves.RequestFilterValve.process(RequestFilterValve.java:210)
        at org.apache.catalina.valves.RemoteAddrValve.invoke(RemoteAddrValve.java:85)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:151)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:269)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:300)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:662)

        The lookup of java:comp/UserTransaction is OK but not java:comp/TransactionManager.

        Show
        Werner Froidevaux added a comment - You can put the code below in a JSP of any WAR and watch the console output. <% String jndiName = null; try { javax.naming.Context context = new javax.naming.InitialContext(); jndiName = "java:comp/UserTransaction"; Object obj = context.lookup(jndiName); System.out.println("lookup of " + jndiName + " OK"); jndiName = "java:comp/TransactionManager"; obj = context.lookup(jndiName); System.out.println("lookup of " + jndiName + " OK"); } catch(Exception e) { System.out.println("lookup of " + jndiName + " FAILED"); e.printStackTrace(); } %> E.g. I put it in ./webapps/openejb/index.jsp and get the following output: lookup of java:comp/UserTransaction OK lookup of java:comp/TransactionManager FAILED javax.naming.NameNotFoundException: Name TransactionManager is not bound in this Context at org.apache.naming.NamingContext.lookup(NamingContext.java:803) at org.apache.naming.NamingContext.lookup(NamingContext.java:145) at org.apache.naming.NamingContext.lookup(NamingContext.java:814) at org.apache.naming.NamingContext.lookup(NamingContext.java:159) at org.apache.naming.SelectorContext.lookup(SelectorContext.java:158) at javax.naming.InitialContext.lookup(InitialContext.java:392) at org.apache.jsp.index_jsp._jspService(index_jsp.java:94) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:433) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333) at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:185) at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:44) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) at org.apache.catalina.valves.RequestFilterValve.process(RequestFilterValve.java:210) at org.apache.catalina.valves.RemoteAddrValve.invoke(RemoteAddrValve.java:85) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:151) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:269) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:300) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662) The lookup of java:comp/UserTransaction is OK but not java:comp/TransactionManager.
        Hide
        Romain Manni-Bucau added a comment -

        it should work in a servlet for instance, in jsp naming is a bit different (at least in TomEE, i think eveything is bound in comp/env)

        Show
        Romain Manni-Bucau added a comment - it should work in a servlet for instance, in jsp naming is a bit different (at least in TomEE, i think eveything is bound in comp/env)
        Hide
        Werner Froidevaux added a comment -

        When I list the bindings under 'java:comp/env' I get

        Binding=comp
        Binding=module

        When I list the bindings under 'java:comp/env/comp' I get

        Binding=TransactionManager: org.apache.naming.ResourceEnvRef
        Binding=BeanManager: org.apache.naming.ResourceEnvRef
        Binding=Validator: org.apache.naming.ResourceEnvRef
        Binding=ValidatorFactory: org.apache.naming.ResourceEnvRef
        Binding=TransactionSynchronizationRegistry: org.apache.naming.ResourceEnvRef
        Binding=ComponentName: java.lang.String

        When I try to lookup the TransactionManager with java:comp/env/comp/TransactionManager I get the exception below. Something seems to be weird with the InitialContext:

        lookup of name java:comp/env/comp/TransactionManager FAILED
        javax.naming.NameNotFoundException: Name "Resource/comp/TransactionManager" not found.
        at org.apache.openejb.core.ivm.naming.IvmContext.federate(IvmContext.java:198)
        at org.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java:152)
        at org.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java:124)
        at org.apache.tomee.common.AbstractObjectFactory.lookup(AbstractObjectFactory.java:80)
        at org.apache.tomee.common.AbstractObjectFactory.getObjectInstance(AbstractObjectFactory.java:48)
        at org.apache.tomee.common.ResourceFactory.getObjectInstance(ResourceFactory.java:49)
        at org.apache.naming.factory.ResourceEnvFactory.getObjectInstance(ResourceEnvFactory.java:114)
        at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:826)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:145)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:814)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:145)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:814)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:145)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:814)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:159)
        at org.apache.naming.SelectorContext.lookup(SelectorContext.java:158)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at org.apache.jsp.index_jsp._jspService(index_jsp.java:99)

        Show
        Werner Froidevaux added a comment - When I list the bindings under 'java:comp/env' I get Binding=comp Binding=module When I list the bindings under 'java:comp/env/comp' I get Binding=TransactionManager: org.apache.naming.ResourceEnvRef Binding=BeanManager: org.apache.naming.ResourceEnvRef Binding=Validator: org.apache.naming.ResourceEnvRef Binding=ValidatorFactory: org.apache.naming.ResourceEnvRef Binding=TransactionSynchronizationRegistry: org.apache.naming.ResourceEnvRef Binding=ComponentName: java.lang.String When I try to lookup the TransactionManager with java:comp/env/comp/TransactionManager I get the exception below. Something seems to be weird with the InitialContext: lookup of name java:comp/env/comp/TransactionManager FAILED javax.naming.NameNotFoundException: Name "Resource/comp/TransactionManager" not found. at org.apache.openejb.core.ivm.naming.IvmContext.federate(IvmContext.java:198) at org.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java:152) at org.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java:124) at org.apache.tomee.common.AbstractObjectFactory.lookup(AbstractObjectFactory.java:80) at org.apache.tomee.common.AbstractObjectFactory.getObjectInstance(AbstractObjectFactory.java:48) at org.apache.tomee.common.ResourceFactory.getObjectInstance(ResourceFactory.java:49) at org.apache.naming.factory.ResourceEnvFactory.getObjectInstance(ResourceEnvFactory.java:114) at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304) at org.apache.naming.NamingContext.lookup(NamingContext.java:826) at org.apache.naming.NamingContext.lookup(NamingContext.java:145) at org.apache.naming.NamingContext.lookup(NamingContext.java:814) at org.apache.naming.NamingContext.lookup(NamingContext.java:145) at org.apache.naming.NamingContext.lookup(NamingContext.java:814) at org.apache.naming.NamingContext.lookup(NamingContext.java:145) at org.apache.naming.NamingContext.lookup(NamingContext.java:814) at org.apache.naming.NamingContext.lookup(NamingContext.java:159) at org.apache.naming.SelectorContext.lookup(SelectorContext.java:158) at javax.naming.InitialContext.lookup(InitialContext.java:392) at org.apache.jsp.index_jsp._jspService(index_jsp.java:99)
        Hide
        Romain Manni-Bucau added a comment -

        can you have a try with the last version which will be available https://repository.apache.org/content/groups/snapshots/org/apache/openejb/apache-tomee/1.0.0-beta-2-SNAPSHOT/ (it should ends with 11.<extension>, if you don't find it you can simply override <tomee>/webapps/openejb/lib/tomee-catalina*.jar with https://repository.apache.org/content/groups/snapshots/org/apache/openejb/tomee-catalina/4.0.0-beta-2-SNAPSHOT/tomee-catalina-4.0.0-beta-2-20111019.211117-10.jar).

        i think both lookup will work: java:comp/env/comp/TransactionManager and java:comp/TransactionManager

        Show
        Romain Manni-Bucau added a comment - can you have a try with the last version which will be available https://repository.apache.org/content/groups/snapshots/org/apache/openejb/apache-tomee/1.0.0-beta-2-SNAPSHOT/ (it should ends with 11.<extension>, if you don't find it you can simply override <tomee>/webapps/openejb/lib/tomee-catalina *.jar with https://repository.apache.org/content/groups/snapshots/org/apache/openejb/tomee-catalina/4.0.0-beta-2-SNAPSHOT/tomee-catalina-4.0.0-beta-2-20111019.211117-10.jar ). i think both lookup will work: java:comp/env/comp/TransactionManager and java:comp/TransactionManager
        Hide
        Werner Froidevaux added a comment -

        tomee-catalina-4.0.0-beta-2-20111019.211117-10.jar works.

        Perfect!

        Show
        Werner Froidevaux added a comment - tomee-catalina-4.0.0-beta-2-20111019.211117-10.jar works. Perfect!
        Hide
        David Blevins added a comment -
        Show
        David Blevins added a comment - 2011-10-19 - http://svn.apache.org/viewvc?view=revision&revision=1186457 - rmannibucau

          People

          • Assignee:
            Romain Manni-Bucau
            Reporter:
            Werner Froidevaux
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development