In order to produce a Web Applicaiton Archive file suitable for deployment to a JEE compliant web server we need to configure the Maven WAR plugin. If we have respected the directory structure that was created with the webapp archetype this is pretty simple bar a few dependency configurations. This entry in our pom.xml says we are going to use the Maven war plugin.
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.0</version> <configuration></configuration> </plugin>
It generates a War file in the target directory. The name of this war file is based on the artifactId and the version number and will be SpringJPA-1.0.war in the example given below.
<artifactId>SpringJPA</artifactId> <packaging>war</packaging> <version>1.0</version>
We can build the package either with the mvn package command, which also runs our unit tests or with mvn compile; mvn war:war.
We will need some more dependencies. Namely the jstl.jar and standard.jar libraries for the JSTL package. When I originally located the JSTL library I got the following message
Downloading: http://repo1.maven.org/maven2/jboss/jboss-common-core/2.0.4.GA/jboss-common-core-2.0.4.GA.pom Downloading: http://repo1.maven.org/maven2/jstl/jstl/1.1.2/jstl-1.1.2.pom 688b downloaded [WARNING] While downloading jstl:jstl:1.1.2 This artifact has been relocated to javax.servlet:jstl:1.1.2.
This simply meant that the JSTL library had been moved and I had to update the groupId from jstl to javax.servlet.
<dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <scope>runtime</scope> <version>1.1.2</version> </dependency> <dependency> <groupId>taglibs</groupId> <artifactId>standard</artifactId> <scope>runtime</scope> <version>1.1.2</version> </dependency>
These are only required at runtime (deployment) so we can scope them appropriately. If you forget these or have the wrong versions your application won't run and you will see the following error in the log file (i.e. tomcat/logs/catalina.out)
SEVERE: Servlet.service() for servlet jsp threw exception org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:51) at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.j