See apache issue reported as a bug.
http://issues.apache.org/bugzilla/show_bug.cgi?id=38242
and
http://issues.apache.org/bugzilla/show_bug.cgi?id=34107
Many classes implement HttpSessionBindingListener instead of HttpSessionListener. This causes a problem with Tomcat 5.5.12 when they try and unbind values from the session, but the call to getSessionId returns null, and throws an invalidStateException. The spec. states that the HttpSessionBindingListener "causes an object to be notified when it is bound to[,] or unbound from a session." The HttpSessionListener spec states, "implementations of this interface are notified of changes to the list of active sessions in a web application."
UPortal is wanting to unbind values when the session is destroyed, therefore it should implement the HttpSessionListener, not the HttpSessionBindingListener. There is no guarantee that all portal containers will implement this correctly and have a valid session once session.invalidate() has been called.
This worked fine in earlier Tomcat versions, however the current implementation is not correct. All classes that implement HttpSessionBindingListener need to be changed to implement HttpSessionListener, and all methods that receive a HttpSessionBindingEvent need to be changed to receive a HttpSessionEvent.
Classes effected:
org.jasig.portal.GuestUserInstance
org.jasig.portal.GuestUserPreferencesManager
org.jasig.portal.GuestUserPreferencesManagerWrapper
org.jasig.portal.IUserPreferencesManager
org.jasig.portal.UserInstance
org.jasig.portal.UserInstanceManager
org.jasig.portal.UserPreferencesManager
org.jasig.portal.jndi.JNDIManager
Example Fix:
Current Version:
public class UserInstance implements HttpSessionBindingListener
{
public void valueUnbound(HttpSessionBindingEvent bindingEvent)
{
}
public void valueBound (HttpSessionBindingEvent bindingEvent)
{
}
}
public class GuestUserPreferencesManager extends UserPreferencesManager
{
public void finishedSession(HttpSessionBindingEvent bindingEvent, String sessionId)
{
}
}
Fix version:
public class UserInstance implements HttpSessionListener
{
public void sessionDestroyed(HttpSessionEvent bindingEvent)
{
}
public void sessionCreated (HttpSessionEvent bindingEvent)
{
}
}
public class GuestUserPreferencesManager extends UserPreferencesManager
{
public void finishedSession(HttpSessionEvent bindingEvent, String sessionId)
{
}
This doesn't seem to cause any bad behavior in uPortal, it is just annoying. I get the following error in my logs a lot:
ERROR [ContainerBackgroundProcessor[StandardEngine[Catalina]]] portlet.CPortletAdapter.[] Sep/28 08:29:50 - java.lang.IllegalStateException: invalidate: Session already invalidate
d
java.lang.IllegalStateException: invalidate: Session already invalidated
at org.apache.catalina.session.StandardSession.invalidate(StandardSession.java:1096)
at org.apache.catalina.session.StandardSessionFacade.invalidate(StandardSessionFacade.java:150)
at org.apache.pluto.core.impl.PortletSessionImpl.invalidate(PortletSessionImpl.java:81)
at org.jasig.portal.channels.portlet.CPortletAdapter.receiveEvent(CPortletAdapter.java:367)
at org.jasig.portal.ChannelManager.finishedSession(ChannelManager.java:289)
at org.jasig.portal.UserInstance.valueUnbound(UserInstance.java:749)
at org.jasig.portal.UserInstanceManager$UserInstanceHolder.valueUnbound(UserInstanceManager.java:134)
at org.apache.catalina.session.StandardSession.removeAttributeInternal(StandardSession.java:1625)
at org.apache.catalina.session.StandardSession.expire(StandardSession.java:749)
at org.apache.catalina.session.StandardSession.isValid(StandardSession.java:581)
at org.apache.catalina.session.ManagerBase.processExpires(ManagerBase.java:679)
at org.apache.catalina.session.ManagerBase.backgroundProcess(ManagerBase.java:664)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1285)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1570)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1579)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1579)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1559)
at java.lang.Thread.run(Thread.java:595)