Geronimo
  1. Geronimo
  2. GERONIMO-3528

Cannot lookup JNDI context inside some servlet event listeners.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.1.1, 2.0.1
    • Fix Version/s: 2.0.3, 2.1
    • Component/s: naming
    • Security Level: public (Regular issues)
    • Labels:
      None

      Description

      In some servlet event listeners, JNDI context lookup fails.
      I encountered this issue while testing the following use case:

      • When http session has became invalid by timeout, web container automatically updates the logoff datetime to database system.

      So I have made sample application to reproduce this issue and the tested results.
      This stack trace is one of NG results:
      16:23:35,661 ERROR [[/examples]] Session event listener threw exception
      java.lang.NullPointerException
      at org.apache.xbean.naming.context.ContextFlyweight.lookup(ContextFlyweight.java:44)
      at org.apache.xbean.naming.context.ContextFederation.getFederatedBinding(ContextFederation.java:71)
      at org.apache.xbean.naming.context.AbstractFederatedContext.getBinding(AbstractFederatedContext.java:63)
      at org.apache.xbean.naming.context.AbstractContext.lookup(AbstractContext.java:129)
      at org.apache.xbean.naming.context.AbstractContext.lookup(AbstractContext.java:611)
      at org.apache.xbean.naming.context.AbstractContext.lookup(AbstractContext.java:152)
      at org.apache.xbean.naming.context.AbstractContext.lookup(AbstractContext.java:597)
      at javax.naming.InitialContext.lookup(InitialContext.java:351)
      at examples.DBConnector.testConnection(DBConnector.java:26)
      at examples.HttpSessionListenerImpl.sessionDestroyed(HttpSessionListenerImpl.java:15)
      at org.apache.catalina.session.StandardSession.expire(StandardSession.java:702)
      at org.apache.catalina.session.StandardSession.isValid(StandardSession.java:592)
      at org.apache.catalina.session.ManagerBase.processExpires(ManagerBase.java:682)
      at org.apache.catalina.session.ManagerBase.backgroundProcess(ManagerBase.java:667)
      at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1316)
      at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
      at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
      at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
      at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
      at java.lang.Thread.run(Thread.java:595)

      If Geronimo v1.1, the stack trace is:
      [ERROR] HttpSession - SystemDatabase doesn't have been lookuped from JNDI Context.
      javax.naming.NameNotFoundException: comp/env/jdbc/SystemDatasource
      at org.apache.geronimo.naming.java.RootContext.lookup(RootContext.java:45)
      at javax.naming.InitialContext.lookup(InitialContext.java:351)
      at examples.DBConnector.testConnection(DBConnector.java:26)
      at examples.HttpSessionListenerImpl.sessionDestroyed(HttpSessionListenerImpl.java:15)
      at org.apache.catalina.session.StandardSession.expire(StandardSession.java:685)
      at org.apache.catalina.session.StandardSession.isValid(StandardSession.java:577)
      at org.apache.catalina.session.ManagerBase.processExpires(ManagerBase.java:678)
      at org.apache.catalina.session.ManagerBase.backgroundProcess(ManagerBase.java:663)
      at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1283)
      at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1568)
      at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1577)
      at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1577)
      at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1557)
      at java.lang.Thread.run(Thread.java:595)

      1. TestedResults2_including_G3667.html
        2 kB
        Kan Ogawa
      2. TestedResults_including_G3667.html
        2 kB
        Kan Ogawa
      3. TestedResults.html
        0.9 kB
        Kan Ogawa
      4. examples.war
        14 kB
        Kan Ogawa

        Issue Links

          Activity

          Hide
          Kan Ogawa added a comment -

          Attached sample web application.

          Show
          Kan Ogawa added a comment - Attached sample web application.
          Hide
          Kan Ogawa added a comment -

          Attached the tested results.

          Show
          Kan Ogawa added a comment - Attached the tested results.
          Hide
          Kan Ogawa added a comment -

          Isn't this issue related to the following topic?
          http://www.nabble.com/java%3Acomp-JNDI-lookup-seems-to-fail-after-server-restart-tf4584712s134.html

          In my tested sample application, the context root is "/examples".

          Show
          Kan Ogawa added a comment - Isn't this issue related to the following topic? http://www.nabble.com/java%3Acomp-JNDI-lookup-seems-to-fail-after-server-restart-tf4584712s134.html In my tested sample application, the context root is "/examples".
          Hide
          Jarek Gawor added a comment -

          Committed fixes to trunk (revision 601860).

          Show
          Jarek Gawor added a comment - Committed fixes to trunk (revision 601860).
          Hide
          Jarek Gawor added a comment -

          Committed fix to branches/2.0 (revision 601864).

          Btw Jetty does not have this problem (at least in trunk).

          Show
          Jarek Gawor added a comment - Committed fix to branches/2.0 (revision 601864). Btw Jetty does not have this problem (at least in trunk).
          Hide
          Kan Ogawa added a comment -

          Jarek,

          I has re-tested this issue, using the 2.0.3 snapshot with your fix.
          In HttpSessionListener#destroyed callback case only, JNDI lookup fails.
          For more detail, see my atteched tested results.

          Show
          Kan Ogawa added a comment - Jarek, I has re-tested this issue, using the 2.0.3 snapshot with your fix. In HttpSessionListener#destroyed callback case only, JNDI lookup fails. For more detail, see my atteched tested results.
          Hide
          Jarek Gawor added a comment -

          Did you build 2.0.3-SNAPSHOT from source code or downloaded a published snapshot?

          Show
          Jarek Gawor added a comment - Did you build 2.0.3-SNAPSHOT from source code or downloaded a published snapshot?
          Hide
          Kan Ogawa added a comment -

          My tested v2.0.3-SNAPSHOT was built from current source code.

          Show
          Kan Ogawa added a comment - My tested v2.0.3-SNAPSHOT was built from current source code.
          Hide
          Jarek Gawor added a comment -

          Can you do svn update and build again becuase I'm not seeing this problem anymore.

          Show
          Jarek Gawor added a comment - Can you do svn update and build again becuase I'm not seeing this problem anymore.
          Hide
          Jarek Gawor added a comment -

          Here's part of the output using your example.war:

          [INFO] ServletRequest Destroyed.
          [INFO] ServletRequest - JNDI Context 'javax.naming.InitialContext@1d2a35d' has been constructed.
          [INFO] ServletRequest - SystemDatabase has been lookuped from JNDI Context and been connected.
          [INFO] HttpSession Destroyed.
          [INFO] HttpSession - JNDI Context 'javax.naming.InitialContext@128b564' has been constructed.
          [INFO] HttpSession - SystemDatabase has been lookuped from JNDI Context and been connected.
          [INFO] HttpSession Attribute 'sessAttr1' Removed.
          [INFO] HttpSession Attribute - JNDI Context 'javax.naming.InitialContext@1c6849' has been constructed.
          [INFO] HttpSession Attribute - SystemDatabase has been lookuped from JNDI Context and been connected.

          Show
          Jarek Gawor added a comment - Here's part of the output using your example.war: [INFO] ServletRequest Destroyed. [INFO] ServletRequest - JNDI Context 'javax.naming.InitialContext@1d2a35d' has been constructed. [INFO] ServletRequest - SystemDatabase has been lookuped from JNDI Context and been connected. [INFO] HttpSession Destroyed. [INFO] HttpSession - JNDI Context 'javax.naming.InitialContext@128b564' has been constructed. [INFO] HttpSession - SystemDatabase has been lookuped from JNDI Context and been connected. [INFO] HttpSession Attribute 'sessAttr1' Removed. [INFO] HttpSession Attribute - JNDI Context 'javax.naming.InitialContext@1c6849' has been constructed. [INFO] HttpSession Attribute - SystemDatabase has been lookuped from JNDI Context and been connected.
          Hide
          Kan Ogawa added a comment -

          Jarek,

          Today, I will build the latest branch/2.0 source code and test it again.

          By the way, what is svn revision number of your built and tested snapshot?

          Show
          Kan Ogawa added a comment - Jarek, Today, I will build the latest branch/2.0 source code and test it again. By the way, what is svn revision number of your built and tested snapshot?
          Hide
          Kan Ogawa added a comment -

          Jarek,

          I have rebuilt snapshot from current source code (r602608) and retested it.
          As you say, I have verified that all test cases are OK results.
          I have uploaded the test results again. Thank you for supporting!

          Show
          Kan Ogawa added a comment - Jarek, I have rebuilt snapshot from current source code (r602608) and retested it. As you say, I have verified that all test cases are OK results. I have uploaded the test results again. Thank you for supporting!
          Hide
          Jarek Gawor added a comment -

          Great! Thanks for double checking.

          Show
          Jarek Gawor added a comment - Great! Thanks for double checking.

            People

            • Assignee:
              Jarek Gawor
              Reporter:
              Kan Ogawa
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development