Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There are many possibilities on what could be going wrong.</p> <ul> <li>There could be two different sessions.</li> <li>There could be some code removing your configuration object from the session.</li> <li>Others?</li> </ul> <p>Here is a way you can test to see what exactly is going on.</p> <p>There are two separate listener interfaces that you can implement to listen for specific session events: <a href="http://download.oracle.com/docs/cd/E17802_01/products/products/servlet/2.3/javadoc/javax/servlet/http/HttpSessionListener.html" rel="nofollow">javax.servlet.http.HttpSessionListener</a> and <a href="http://download.oracle.com/docs/cd/E17802_01/products/products/servlet/2.3/javadoc/javax/servlet/http/HttpSessionAttributeListener.html" rel="nofollow">javax.servlet.http.HttpSessionAttributeListener</a></p> <p>I would implement these two interfaces with a class that will log what is happening during each event and which session the event is coming from.</p> <p>You should be able to easily add your listeners to your web.xml file so that they will actually be set as listeners on your sessions by tomcat.</p> <p><strong>EDIT</strong></p> <p>Here is a class you can place into your web.xml as a listener to your sessions. Both BalusC and myself have recommended that you try this approach to debug the issue. Please just humor us and let us know if you see anything interesting in the way your "configuration" attribute is being set?</p> <pre><code>import javax.servlet.http.HttpSessionActivationListener; import javax.servlet.http.HttpSessionAttributeListener; import javax.servlet.http.HttpSessionBindingEvent; import javax.servlet.http.HttpSessionBindingListener; import javax.servlet.http.HttpSessionEvent; import javax.servlet.http.HttpSessionListener; public class SessionListener implements HttpSessionListener, HttpSessionAttributeListener, HttpSessionBindingListener, HttpSessionActivationListener { public void valueBound(HttpSessionBindingEvent event) { System.out.println("valueBound: " + event.getName() + " : " + event.getValue()); System.out.println(" session: " + event.getSession().getId()); this.printStackTrace(); } public void valueUnbound(HttpSessionBindingEvent event) { System.out.println("valueUnbound: " + event.getName() + " : " + event.getValue()); System.out.println(" session: " + event.getSession().getId()); this.printStackTrace(); } public void attributeAdded(HttpSessionBindingEvent event) { System.out.println("attributeAdded: " + event.getName() + " : " + event.getValue()); System.out.println(" session: " + event.getSession().getId()); this.printStackTrace(); } public void attributeRemoved(HttpSessionBindingEvent event) { System.out.println("attributeRemoved: " + event.getName() + " : " + event.getValue()); System.out.println(" session: " + event.getSession().getId()); this.printStackTrace(); } public void attributeReplaced(HttpSessionBindingEvent event) { System.out.println("attributeReplaced: " + event.getName() + " : " + event.getValue()); System.out.println(" session: " + event.getSession().getId()); this.printStackTrace(); } public void sessionCreated(HttpSessionEvent event) { System.out.println("sessionCreated: " + event.getSession().getId()); this.printStackTrace(); } public void sessionDestroyed(HttpSessionEvent event) { System.out.println("sessionDestroyed: " + event.getSession().getId()); this.printStackTrace(); } public void sessionDidActivate(HttpSessionEvent event) { System.out.println("sessionDidActivate: " + event.getSession().getId()); this.printStackTrace(); } @Override public void sessionWillPassivate(HttpSessionEvent event) { System.out.println("sessionWillPassivate: " + event.getSession().getId()); this.printStackTrace(); } private void printStackTrace() { try { if (true) { throw new Exception(); } } catch (Exception e) { e.printStackTrace(); } } } </code></pre> <p>Please add the above class to your code then add the following to your web.xml file between your filter mappings and your servlet mappings:</p> <pre><code>&lt;listener&gt; &lt;listener-class&gt;&lt;your.package.name&gt;SessionListener&lt;/listener-class&gt; &lt;/listener&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload