Hi to all,
I try to use
mvn tomcat7:run
and it works fine until I use HttpSessionListener in my web.xml.
I implement these SessionCounter
public class SessionCounter implements HttpSessionListener { ... }
and set it in my web.xml:
<listener>
<listener-class>app.listeners.SessionCounter</listener-class>
</listener>
It works when running via
mvn jetty:run
but fails with
mvn tomcat7:run
because Tomcat cannot start:
SEVERE: Exception starting filter dispatcher
java.lang.ClassCastException: org.javalite.activeweb.RequestDispatcher cannot be cast to javax.servlet.Filter
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:107)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4775)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5452)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
I quess there is some duplicity in classpath and try change my pom.xml to has javax.servlet-api "provided":
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
But I got
org.javalite.activeweb.CompilationException: src/main/java/app/controllers/ContentController.java:27: error: cannot access HttpSessionListener
SessionCounter counter = session().get("counter", SessionCounter.class);
^
class file for javax.servlet.http.HttpSessionListener not found
1 error
at org.javalite.activeweb.DynamicClassFactory.getCompiledClass(DynamicClassFactory.java:47)
at org.javalite.activeweb.DynamicClassFactory.createInstance(DynamicClassFactory.java:23)
at org.javalite.activeweb.ControllerFactory.createControllerInstance(ControllerFactory.java:27)
at org.javalite.activeweb.Router.recognize(Router.java:79)
so it looks like there is no javax.servlet duplicity? I stuck in this point.
Important notice: There no problem to run application in normal Tomcat/Jetty deployments.
Any ideas how to solve this? It is not hot problem but is should be nice to be able to run both tomcat and jetty from maven...
Best regards,
Ondrej Nemecek.