permaculture playing cards
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
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "tomcat6 class not found: ServletContextListener" Watch "tomcat6 class not found: ServletContextListener" New topic

tomcat6 class not found: ServletContextListener

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

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:


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.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: tomcat6 class not found: ServletContextListener
jQuery in Action, 3rd edition