How to setup a HttpSessionListener ?

238 views
Skip to first unread message

OlivierMatt

unread,
Apr 5, 2007, 4:39:55 AM4/5/07
to Google Web Toolkit
Hi,

I am trying to setup an HttpSessionListener for my GWT application.

I edited the tomcat/conf/gwt/web.xml and added inside the <web-app> </
web-app> the following lines:

<listener>
<listener-class>xft.oli.server.SessionListener</listener-class>
</listener>


Here`s the coding for the xft.oli.server.SessionListener class:

package xft.oli.test.server;

import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

public class SessionListener implements HttpSessionListener {

public void sessionCreated(HttpSessionEvent arg0) {
// TODO Auto-generated method stub
System.out.println("session created");
}

public void sessionDestroyed(HttpSessionEvent arg0) {
// TODO Auto-generated method stub
System.out.println("session destroyed");
}

}

I am not sure that I am doing this setup correctly.

So here's what I get in the GWT console:

[WARN] StandardContext[]Error configuring application listener of
class xft.oli.server.SessionListener
java.lang.ClassNotFoundException: xft.oli.server.SessionListener
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:
1340)
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:
1189)
at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:
3775)
at
org.apache.catalina.core.StandardContext.start(StandardContext.java:
4343)
at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:
823)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:
807)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:
595)
at
org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.java:
277)
at org.apache.catalina.core.StandardHost.install(StandardHost.java:
832)
at
org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:
701)


And then in my browser I get a error 404 message informing that the
page is not available.

Let me know if you ideas how to solve this problem,

Sincerely,

Olivier MATT

Steiner Dominik, (QX59311)

unread,
Apr 5, 2007, 4:57:36 AM4/5/07
to Google-We...@googlegroups.com
Hi Olivier,

I would strongly recommend to use an external server instead of the built in one. (see -noserver posts in the forum for setting it up)

But meanwhile you should change the web.xml under tomcat/webapps/ROOT/WEB-INF and add your listener there. (and not under conf/gwt)

HTH

Dominik

-----Ursprüngliche Nachricht-----
Von: Google-We...@googlegroups.com [mailto:Google-We...@googlegroups.com] Im Auftrag von OlivierMatt
Gesendet: Donnerstag, 5. April 2007 10:40
An: Google Web Toolkit
Betreff: How to setup a HttpSessionListener ?

Dan Morrill

unread,
Apr 5, 2007, 9:47:50 AM4/5/07
to Google-We...@googlegroups.com
Hello!

One thing about GWT that is not obvious is that it does not compile your Java source code for you.  That is, any .java source code files that you create for use on the server (such as your session listener) must be compiled manually -- neither the hosted mode shell nor the GWT compiler will ever run javac. Most IDEs will automatically compile .java files as you work with them, but if you're not using one then you need to run javac manually.

You didn't say whether you're using an IDE, so one easy thing to test is whether your server-side .java files have been compiled to .class files.  The next thing to check is that they are in the classpath appropriately.

If that's all correct, then Dominick's suggestion to switch to an external server via the "-noserver" mechanism is a good one.  The embedded Tomcat instance is great for getting up and running quickly, but it can be a little tricky to configure, and you may find it simpler to work with your favorite server.

- Dan Morrill
Reply all
Reply to author
Forward
0 new messages