glassfish
  1. glassfish
  2. GLASSFISH-17800

Glassfish does not comply with EJB3.1 specs: NameNotFoundException not thrown when looking up UserTransaction for CMT

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Invalid
    • Affects Version/s: 3.1.1
    • Fix Version/s: None
    • Component/s: naming
    • Labels:
      None
    • Environment:

      GlassFish 3.1.1/3.1.2.b10
      Weld 1.1.3.Final/1.1.4-SNAPSHOT(build: 2011-11-22)
      JDK 1.6.0_29
      Windows XP SP3

      Description

      According to the EJB 3.1 specification (section 16.12 on page 473), the container should throw a NameNotFoundException when looking up java:comp/UserTransaction for CMT.

      When invoke InitialContext.lookup("java:comp/UserTransaction") within a session bean(stateless or stateful),
      Glassfish just throw NamingException from SerialContext line 518.
      This behavior does not comply with the specification.

      Caused by: javax.naming.NamingException: Lookup failed for 'java:comp/UserTransaction' in SerialContext[myEnv=

      {java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming}

      [Root exception is javax.naming.NameNotFoundException: Lookup of java:comp/UserTransaction not allowed for Container managed Transaction beans]
      at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:518)
      at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
      at javax.naming.InitialContext.lookup(InitialContext.java:392)
      at javax.naming.InitialContext.lookup(InitialContext.java:392)

      The following is an excerpt from the "JSR-000318 Enterprise JavaBeans 3.1 Proposed Final Draft Specification".
      (http://download.oracle.com/otndocs/jcp/ejb-3.1-pfd-oth-JSpec/)

      section 4.6.1 on page 95:
      The UserTransaction interface is unavailable to enterprise beans with container-managed transaction demarcation.

      section 16.12 on page 473:
      The container must not make the UserTransaction interface available to the enterprise beans that are not allowed to use this interface. The container should throw javax.naming.NameNotFoundException if an instance of an enterprise bean that is not allowed to use the UserTransactioninterface attempts to look up the interface in JNDI using the JNDI APIs.

      This issue is very similar to
      http://java.net/jira/browse/GLASSFISH-3356
      and
      http://java.net/jira/browse/GLASSFISH-1538

        Activity

        Hide
        Cheng Fang added a comment -

        Just tried with both trunk build and 3.1.2 builds, got the expected NameNotFoundException thrown from ejb container:

        Caused by: javax.naming.NamingException: Lookup failed for 'java:comp/UserTransaction' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NameNotFoundException: Lookup of java:comp/UserTransaction not allowed for Container managed Transaction beans]
                at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:518)
                at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
                at javax.naming.InitialContext.lookup(InitialContext.java:392)
                at javax.naming.InitialContext.lookup(InitialContext.java:392)
                at javax.naming.InitialContext.doLookup(InitialContext.java:265)
                at test.TestBean.hello(TestBean.java:12)
                ... 62 more
        Caused by: javax.naming.NameNotFoundException: Lookup of java:comp/UserTransaction not allowed for Container managed Transaction beans
                at com.sun.ejb.containers.BaseContainer.checkUserTransactionLookup(BaseContainer.java:838)
                at com.sun.ejb.EjbInvocation.userTransactionLookupAllowed(EjbInvocation.java:427)
                at com.sun.enterprise.transaction.TransactionNamingProxy.checkUserTransactionLookupAllowed(TransactionNamingProxy.java:162)
                at com.sun.enterprise.transaction.TransactionNamingProxy.handle(TransactionNamingProxy.java:135)
                at com.sun.enterprise.naming.impl.NamedNamingObjectManager.tryNamedProxies(NamedNamingObjectManager.java:89)
                at com.sun.enterprise.naming.impl.JavaURLContext.lookup(JavaURLContext.java:174)
                at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:498)
                ... 67 more
        |#]
        
        Show
        Cheng Fang added a comment - Just tried with both trunk build and 3.1.2 builds, got the expected NameNotFoundException thrown from ejb container: Caused by: javax.naming.NamingException: Lookup failed for 'java:comp/UserTransaction' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NameNotFoundException: Lookup of java:comp/UserTransaction not allowed for Container managed Transaction beans] at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:518) at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455) at javax.naming.InitialContext.lookup(InitialContext.java:392) at javax.naming.InitialContext.lookup(InitialContext.java:392) at javax.naming.InitialContext.doLookup(InitialContext.java:265) at test.TestBean.hello(TestBean.java:12) ... 62 more Caused by: javax.naming.NameNotFoundException: Lookup of java:comp/UserTransaction not allowed for Container managed Transaction beans at com.sun.ejb.containers.BaseContainer.checkUserTransactionLookup(BaseContainer.java:838) at com.sun.ejb.EjbInvocation.userTransactionLookupAllowed(EjbInvocation.java:427) at com.sun.enterprise.transaction.TransactionNamingProxy.checkUserTransactionLookupAllowed(TransactionNamingProxy.java:162) at com.sun.enterprise.transaction.TransactionNamingProxy.handle(TransactionNamingProxy.java:135) at com.sun.enterprise.naming.impl.NamedNamingObjectManager.tryNamedProxies(NamedNamingObjectManager.java:89) at com.sun.enterprise.naming.impl.JavaURLContext.lookup(JavaURLContext.java:174) at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:498) ... 67 more |#]
        Hide
        Cheng Fang added a comment -

        TransactionNamingProxy checks if the access is allowed by consulting TransactionOperationManager. For ejb invocation, it is EjbInvocation that decides if the ut access is allowed. As shown in the above comment, NameNotFoundException is thrown if the UserTransaction access is not allowed.

        Show
        Cheng Fang added a comment - TransactionNamingProxy checks if the access is allowed by consulting TransactionOperationManager. For ejb invocation, it is EjbInvocation that decides if the ut access is allowed. As shown in the above comment, NameNotFoundException is thrown if the UserTransaction access is not allowed.
        Hide
        ratking added a comment -

        The issue need to fix.

        Show
        ratking added a comment - The issue need to fix.

          People

          • Assignee:
            Cheng Fang
            Reporter:
            ratking
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: