Translations of this page:

Building the Spring MVC WAR with Maven

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.


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.


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

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.


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:
  cannot be resolved in either web.xml or the jar files deployed with this application
    at org.apache.jasper.compiler.DefaultErrorHandler.jspError(
    at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.j

Part IV: Running our Spring JPA example under Tomcat


tech/java/building-the-spring-mvc-war-with-maven.txt · Last modified: 2007/10/02 17:52 by davidof
Recent changes RSS feed