3 Replies Latest reply on Dec 10, 2001 8:32 PM by jules_gosnell

    JNDI context problem durinh HttpSession lifecycle.

    alexnet

      Problem: I put some object into HttpSession. Object implements HttpSessionBindingListener, in order to perform some operation I've got configuration information from JNDI context. Everything work fine for method 'valueBound(HttpSessionBindingEvent event)', but if I try to work with JNDI from
      method 'valueUnbound(HttpSessionBindingEvent event)',
      I've got NameNotFoundException: conext 'env' not bound. Right now I use workaround - get reference to resource in valueBound method, and hold this reference for later use in valueunBound, but for heavy load this will be not the option.

      I use SUN JDK 1.3.1_01 Server HotSpot VM, Win2K Prof.
      Problem exist on next bundles:
      JBoss 2.4.3+Tomcat 3.2
      JBoss 2.4.3+Tomcat 4.01
      JBoss 3.0alpaha+Jetty
      Here is server log:
      [Default] Unbound from session: 0hkf2a5ei1
      [Default] Event name: TestSessionScopeJNDI
      [Default] javax.naming.NameNotFoundException: env not
      bound
      [Default] at
      org.jnp.server.NamingServer.getBinding
      (NamingServer.java:495)
      [Default]
      [Default] at
      org.jnp.server.NamingServer.getBinding
      (NamingServer.java:503)
      [Default]
      [Default] at
      org.jnp.server.NamingServer.getObject
      (NamingServer.java:509)
      [Default]
      [Default] at org.jnp.server.NamingServer.lookup
      (NamingServer.java:282)
      [Default]
      [Default] at
      org.jnp.interfaces.NamingContext.lookup
      (NamingContext.java:349)
      [Default]
      [Default] at
      org.jnp.interfaces.NamingContext.lookup
      (NamingContext.java:457)
      [Default]
      [Default] at
      org.jnp.interfaces.NamingContext.lookup
      (NamingContext.java:333)
      [Default]
      [Default] at javax.naming.InitialContext.lookup
      (Unknown Source)
      [Default]
      [Default] at JndiPrintBean.valueUnbound(Unknown
      Source)
      [Default]
      [Default] at
      org.apache.tomcat.session.StandardSession.removeAttribu
      te(StandardSession.java:670)
      [Default]
      [Default] at
      org.apache.tomcat.session.StandardSession.expire
      (StandardSession.java:383)
      [Default]
      [Default] at
      org.apache.tomcat.session.StandardManager.processExpire
      s(StandardManager.java:483)
      [Default]
      [Default] at
      org.apache.tomcat.session.StandardManager.run
      (StandardManager.java:553)
      [Default]
      [Default] at java.lang.Thread.run(Unknown Source)
      [Default]


        • 1. Re: JNDI context problem durinh HttpSession lifecycle.
          jules_gosnell

          This sounds like:

          Either,

          The session is being destroyed because the webapp is being destroyed, and the context is tidied up before the session - is your webapp being undeployed at the time you get this error /

          Or,

          Somehow, in the valueUnbound() method your ContextClassLoader has been changed - could you print out Thread.currentThread().getContextClassLoader() in your valueBound() and valueUnbound() methods and let me see it.

          Or,

          Something else...

          Any more information would be helpful.

          Jules


          P.S.

          I am only talking JBoss3/Jetty4, as this is the integration that I am responsible for.....

          • 2. Re: JNDI context problem durinh HttpSession lifecycle.
            alexnet

            Hi Jules,

            I didn't talking about undeploying application. It was just expired session.

            Here is part of logfile:
            valueBound() method:
            [23:48:55,296,Jetty] JSP: init
            [23:48:55,556,Default] Bound into session: 1g294jrp4
            [23:48:55,556,Default] Is session new: true
            [23:48:55,556,Default] Event name: TestSessionScopeJNDI
            [23:48:55,556,Default] ClassLoader: org.mortbay.http.ContextLoader(file:/F:/tools/jboss-3.0.0alpha/deploy/Default/advisor.ear/web1001/WEB-INF/lib/advisor-client.jar;file:/F:/tools/jboss-3.0.0alpha/deploy/Default/advisor.ear/web1001/WEB-INF/
            lib/jboss-client.jar;file:/F:/tools/jboss-3.0.0alpha/deploy/Default/advisor.ear/web1001/WEB-INF/lib/jbosssx-client.jar;file:/F:/tools/jboss-3.0.0alpha/deploy/Default/advisor.ear/web1001/WEB-INF/lib/jnp-client.jar;file:/F:/tools/jboss-3.0.0a
            lpha/deploy/Default/advisor.ear/web1001/WEB-INF/classes/) / java.net.URLClassLoader@48ef56
            [23:48:55,566,Default] +- jdbc (class: org.jnp.interfaces.NamingContext)
            | +- expound (class: org.jnp.interfaces.NamingContext)
            | | +- advisor (class: org.jnp.interfaces.NamingContext)
            | | | +- AnalyticsDS[link -> java:/expound/advisor/AnalyticsDS] (class: j
            avax.naming.LinkRef)
            | | | +- AdvisorDS[link -> java:/expound/advisor/AdvisorDS] (class: javax
            .naming.LinkRef)
            +- ejb (class: org.jnp.interfaces.NamingContext)
            | +- expound (class: org.jnp.interfaces.NamingContext)
            | | +- advisor (class: org.jnp.interfaces.NamingContext)
            | | | +- PSBean[link -> expound/advisor/PSBean] (class: javax.naming.Link
            Ref)
            +- security (class: org.jnp.interfaces.NamingContext)
            | +- realmMapping (class: org.jboss.security.plugins.NullSecurityManager)
            | +- securityMgr (class: org.jboss.security.plugins.NullSecurityManager)
            [23:48:55,696,Jetty] WARNING: Servlet Exception for /advisor/snoop.jsp
            java.util.NoSuchElementException
            at java.util.AbstractList$Itr.next(Unknown Source)
            at java.util.Collections$6.nextElement(Unknown Source)
            at org.mortbay.jetty.servlet.ServletRequest.getLocale(ServletRequest.jav
            a:162)
            at _0002fsnoop_0002ejspsnoop_jsp_0._jspService(_0002fsnoop_0002ejspsnoop
            _jsp_0.java:282)
            at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
            at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspSer
            vlet.java:176)
            at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3
            07)
            at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:380)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
            at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:488
            )
            at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:3
            87)
            at org.mortbay.http.HandlerContext.handle(HandlerContext.java:1040)
            at org.mortbay.http.HandlerContext.handle(HandlerContext.java:995)
            at org.mortbay.http.HttpServer.service(HttpServer.java:683)
            at org.mortbay.http.HttpConnection.service(HttpConnection.java:732)
            at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:889)
            at org.mortbay.http.HttpConnection.handle(HttpConnection.java:746)
            at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:
            146)
            at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:287)
            at org.mortbay.util.ThreadPool$PoolThreadRunnable.run(ThreadPool.java:60
            9)
            at java.lang.Thread.run(Unknown Source)
            valueUnbound() method:
            [23:57:15,665,JmsXA] running gc for pool
            [23:57:15,665,DefaultDS] running gc for pool
            [23:57:15,665,NoTransDS] running gc for pool
            [23:58:58,413,Default] Unbound from session: 1g294jrp4
            [23:59:08,758,Default] Event name: TestSessionScopeJNDI
            [23:59:08,758,Default] ClassLoader: java.net.URLClassLoader@48ef56
            [23:59:08,768,Default] javax.naming.NameNotFoundException: env not bound
            [23:59:08,768,Default] at org.jnp.server.NamingServer.getBinding(NamingServer.j
            ava:495)
            [23:59:08,768,Default] at org.jnp.server.NamingServer.getBinding(NamingServer.j
            ava:503)
            [23:59:08,768,Default] at org.jnp.server.NamingServer.getObject(NamingServer.ja
            va:509)
            [23:59:08,768,Default] at org.jnp.server.NamingServer.lookup(NamingServer.java:
            282)
            [23:59:08,768,Default] at org.jnp.interfaces.NamingContext.lookup(NamingContext
            .java:365)
            [23:59:08,768,Default] at org.jnp.interfaces.NamingContext.lookup(NamingContext
            .java:473)
            [23:59:08,768,Default] at org.jnp.interfaces.NamingContext.lookup(NamingContext
            .java:349)
            [23:59:08,768,Default] at javax.naming.InitialContext.lookup(Unknown Source)
            [23:59:08,768,Default] at JndiPrintBean.valueUnbound(Unknown Source)
            [23:59:08,768,Default] at org.mortbay.jetty.servlet.Context$Session.unbindValue
            (Context.java:815)
            [23:59:08,768,Default] at org.mortbay.jetty.servlet.Context$Session.invalidate(
            Context.java:701)
            [23:59:08,768,Default] at org.mortbay.jetty.servlet.Context.scavenge(Context.ja
            va:547)
            [23:59:08,768,Default] at org.mortbay.jetty.servlet.Context.access$1(Context.ja
            va)
            [23:59:08,768,Default] at org.mortbay.jetty.servlet.Context$SessionScavenger.ru
            n(Context.java:572)

            Is this enough, or I should post the code which I use to traverse JNDI ?

            --Alex.

            • 3. Re: JNDI context problem durinh HttpSession lifecycle.
              jules_gosnell

              Firstly,

              from the getLocale() Exception it looks like you are not running a recently refreshed RH cvs tree.

              If this is the case then you should refresh and rebuild it, otherwise we may waste time on problems that have already been fixed.

              Secondly, the classloader seems to be changing between the two methods. In the first one you get the correct cl and consequently are able to find you JNDI context, in the second method you get the first cl's parent and are not able to locate your context.

              Confirm this on an up-to-date RH tree and I shall take a look at it.

              Jules