• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

tomcat6 class not found: ServletContextListener

 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:

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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic