JAR files you should never include in your web-app
As a rule, the following jar files should never be part of your webapp:
- j2ee.jar - interfaces are implemented by Tomcat (see below)
- jasper-*.jar - causes Exceptions, or will do when version of Tomcat is upgraded
- jsp-api.jar - causes Exceptions, or will do when version of Tomcat is upgraded (see below)
- rt.jar - not sure why you would, but some have...
- servlet-api.jar - this is really old too, switch to compiling with j2ee.jar (see below)
- servlet.jar - this is really old too, switch to compiling with j2ee.jar (see below)
- tools.jar - part of VM
- xerce.jar, xerces.jar and xercesImpl.jar - in Tomcat 5.5 and above these are included in Tomcat already. Having different versions in your application will often cause TLD parsing problems and NoClassDefFoundError errors.
- jboss.jar - part of jboss - should not be part of your app
- gwt-user.jar - contains javax.servlet.Servlet, so gets ignored by Tomcat
- gwt-dev-linux.jar - contains javax.servlet.Servlet, so gets ignored by Tomcat
- gwt-dev-windows.jar - contains javax.servlet.Servlet, so gets ignored by Tomcat
- standard.jar - do not include when using JSTL 1.2 (ie: in Tomcat 6 and above), include correct version when using JSTL 1.0/1.1
You may require these for compiling your app (notably servlet-api.jar or j2ee.jar), but they should not be deployed as part of your webapp.
jsp-api.jar and/or jasper-*.jar
Including these files will cause the following exceptions:
If these aren't thrown when deploying your app, they most likely will be when the version of Tomcat is next updated. By chance, you might be using exactly the same version as the container. They already exist in the container though, so remove them to save yourself future pain.
servlet-api.jar - the most common mistakenly included JAR
Many developers incorrectly include servlet-api.jar in their
WEB-INF/lib folder. This no longer causes an exception because
Tomcat and other app servers will recognize it as a problem when deploying the
JAR file. However, it does cause the container to ignore any
JAR file that contains the
javax/servlet/Servlet.class. In this case, you will see the following warning in the system log:
INFO: validateJarFile(/path/app/WEB-INF/lib/servlet-api.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class