tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ken Bowen <>
Subject SessionListener not being invoked
Date Tue, 01 Dec 2009 17:56:49 GMT

My setup: Mac OS X 10.5.8, Tomcat/6.0.20[from apache],  java version  
I'm starting Tomcat with ~bin/

I have a SessionListener which is not being invoked when I connect to  
the webapp,
and I don't understand why.
The SessionListener works correctly in a a slight variation of the  

The problem circumstance is when the app is running as the default  
ROOT webapp,
by dropping ROOT.war into webapps.

The relevant part of web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
<!-- ============================================ Welcome File List -->
<!-- ============================================ Listener  
Registration -->
<!-- ============================================ Context Parameters -->


The SessionListener class:

package com.strongbrain.listener;

import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
import com.strongbrain.ConfigBean;
import com.strongbrain.Constants;

public class SessionListener implements HttpSessionListener
    public void sessionCreated(HttpSessionEvent httpSessionEvent) {
System.out.println("++++Enter sessionCreated");
       HttpSession session = httpSessionEvent.getSession();
       ConfigBean  configBean = new ConfigBean();
       String baseprefix =

       if (baseprefix != null){
System.out.println("+++++++++SessionListener: isNew="+session.isNew() 
+"  baseprefix="+baseprefix+"  
       session.setAttribute(Constants.CONFIG_BEAN, configBean);

    public void sessionDestroyed(HttpSessionEvent arg0) {

When I start Tomcat with the app (as ROOT.war) in webapps, and then  
connect with a browser,
catalina.out looks like this:

.....(usual stuff)
Dec 1, 2009 12:14:42 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 2823 ms
[Deprecated] Xalan:  
org.apache.xalan.processor.TransformerFactoryImpl     <<<<< Browser  
connect above here
adl=5                                                <<<<< Healthy  
trace output from class invoked on welcome.jsp

Notice that neither of the System.out.println's in the  
SessionListener.sessionCreated method appear.

BUT:  When I run this in the non-ROOT configuration, things work.  In  
that case, the only difference in the code above is in

In that case, catalina.out shows:

Dec 1, 2009 12:30:34 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 3072 ms
++++Enter sessionCreated
+++++++++SessionListener: isNew=true  baseprefix=/strongbrain/  
[Deprecated] Xalan: org.apache.xalan.processor.TransformerFactoryImpl

This behavior is occurring both on my (development) Mac,
and on a remote CentOS 5 system running Tomcat/6.0.18 under java  
version "1.6.0_12"

In all cases, the browser connects to the expected welcome page.

At present, I'm at a loss as to what to look for;  I hope someone here  
can point me in the right direction.
Thanks in advance,
Ken Bowen

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message