• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

tomcat6 class not found: ServletContextListener

Tim Holloway
Saloon Keeper
Posts: 18324
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic