PDA

View Full Version : Using HttpSessionAttributeListener



MicroDat
May 1st, 2007, 10:39 AM
Hi everyone,

I am using spring 2.0.2 and I am trying to implement the HttpSessionAttributeListener interface to response to certain session activities.

Here is my class that implements the interface:



package sessionlistener;

import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionBindingEvent;

public class SessionListener implements HttpSessionAttributeListener {


public SessionListener(){

}

public void attributeAdded(HttpSessionBindingEvent se) {
// TODO Auto-generated method stub

}

public void attributeRemoved(HttpSessionBindingEvent se) {
// TODO Auto-generated method stub

}

public void attributeReplaced(HttpSessionBindingEvent se) {
// TODO Auto-generated method stub

}




<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListe ner
</listener-class>
</listener>

<listener>
<listener-class>
sessionlistener.SessionListener
</listener-class>
</listener>

Here is my web.xml file, notice the two listener tags, this is how I seen some tutorial add two listener class but when I try to start my app with eclipse I get this error:


SEVERE: Error listenerStart

Anyone know a solution to this? Thanks for any help.


Regards,

MD

pmularien
May 1st, 2007, 11:20 AM
It looks like the package name ("sessionlistener") you're using in the listener doesn't match the fully-qualified class name ("com.warnerbros.dete.ui.common.util.session") you've got in your web.xml file.

MicroDat
May 1st, 2007, 11:32 AM
It looks like the package name ("sessionlistener") you're using in the listener doesn't match the fully-qualified class name ("com.warnerbros.dete.ui.common.util.session") you've got in your web.xml file.
Sorry, that isn't the problem. The names are consistent and correct.

karldmoore
May 1st, 2007, 11:47 AM
Have you tried taking out one of the listeners and seeing which is causing it? I would also try googling this and searching the forum, it was brought up recently.
e.g.
http://forum.springframework.org/showthread.php?t=27967

MicroDat
May 1st, 2007, 12:15 PM
Have you tried taking out one of the listeners and seeing which is causing it? I would also try googling this and searching the forum, it was brought up recently.
e.g.
http://forum.springframework.org/showthread.php?t=27967
I have, I've been googling this for the past day and half and searching the forum for answers. No dice. This seems such a trivial thing but I guess with spring it can get quite convoluted.

karldmoore
May 1st, 2007, 12:23 PM
I have, I've been googling this for the past day and half and searching the forum for answers. No dice. This seems such a trivial thing but I guess with spring it can get quite convoluted.

As I said previously have you tracked down which one of these is causing the error? e.g. take one out and try it again. I'm sure someone recommended just unpacking tomcat and trying it with a new copy after spending hours on this.

pmularien
May 1st, 2007, 12:29 PM
Sorry, that isn't the problem. The names are consistent and correct.
Well in that case could you try posting the correct code? Otherwise there's not much we can do to help.