This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes IDEs, Version Control and other tools and the fly likes tomcat6 class not found: ServletContextListener Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "tomcat6 class not found: ServletContextListener" Watch "tomcat6 class not found: ServletContextListener" New topic
Author

tomcat6 class not found: ServletContextListener

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15662
    
  15

This is a note to myself in case I forget. By posting it here, I have an easy way to look it up again. Also it just might help someone else!

tomcat6 java.lang.NoClassDefFoundError: javax/servlet/ServletContextListener

I got this when I moved my technology sandbox webapp to Java 6 and Tomcat 6. My technology sandbox app is currently using JPA (Apache OpenJPA), Hibernate 3, the Spring Framweork and Facelets (JSF). The error actually comes from Spring as it's trying to set up the infrastructure.

Oh yes, and (probably most important) this is using the sysdeo plugin on Eclipse V3.

People have reported similar problems on Tomcat5.

Cause: The web app can't see some of the JEE support classes.

Reason: Apparently, when sysdeo starts up Tomcat 6, the classpath isn't quite right.

Note: I see that in Tomcat 6, the old multiple libraries structure has been replaced. The app-visible libs are now in TOMCAT_HOME/lib (formerly TOMCAT_HOME/common/lib, I believe).

Resolution: The least intrusive way I know to handle this is to instruct the sysdeo plugin to include certain "missing" libraries in its startup classpath. To do this:

1. Open the Eclipse Window/Preferences/Tomcat/JVM Settings menu dialog.

2. Add the following jars to the "Classpath (Before generated classpath)" item:

TOMCAT_HOME/lib/el-api.jar
TOMCAT_HOME/lib/jsp-api.jar
TOMCAT_HOME/lib/servlet-api.jar

I used the actual absolute filename path in place of TOMCAT_HOME, above.

Other jars might be needed depending on the app.

If anyone knows a more proper resolution, please tell me, but this seems to resolve the problem OK without scarring either the app or the installed copy of Tomcat.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: tomcat6 class not found: ServletContextListener
 
Similar Threads
Eclipse projects on removable media
Eclipse 3.0, Lomboz 3.0 & Tomcat 5.0.x problem
need help
How to include servlet api in eclipse
i cant run my program