Monday, July 13

Maven: 'webxml attribute is required' Error

Using web.xml can be tricky sometimes with Maven

The correct location of web.xml is - project\src\main\webapp\WEB-INF\web.xml

PROBLEM:


Although, maven should be automatically picking up this file (Convention Over Configuration right?) but most of the times it fails to do so and burps out this ERROR:

Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode)

SOLUTION:


May look annoying, but try specifying the location explicitly and it works like a charm...

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-war-plugin</artifactId>
  <configuration>
    <webXml>src\main\webapp\WEB-INF\web.xml</webXml>
  </configuration>
</plugin>


Let me know your thoughts about it!