Monday, March 9, 2009

Java web apps in Tomcat

Put as little external libraries as you can into $TOMCAT/commons/lib or $TOMCAT/shared/lib. When time to update comes each shared dependency has a chance of crippling your efforts by breaking seemingly independent applications. In general, you shouldn't add any libraries to aforementioned folders. If your applications must share some of their dependencies - set up a simlink outside of the Tomcat. This way you will have a guarantee that there will be no issues related to the Tomcats classloader.

If you want to maintain j2ee 1.4 compatibility and avoid problems with dependencies on jsp/jstl libraries (dreaded NoClassDefFoundError: Class not found javax/el/ValueExpression) I suggest you use this configuration:

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>

No comments: