Main Tutorials

Maven – webxml attribute is required

Maven package a web application and hits the following error message :

$ mvn package
//...
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war 
(default-war) on project spring4-mvc-maven-ajax-example: 

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

Solution

1. For servlet container < 3, make sure WEB-INF/web.xml file exists.

2. For servlet container >=3, and NO web.xml web application, declares the following maven-war-plugin plugin, and set the failOnMissingWebXml option to false.

pom.xml

  <build>
	<plugins>
		
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-war-plugin</artifactId>
			<version>2.6</version>
			<configuration>
				<failOnMissingWebXml>false</failOnMissingWebXml>
			</configuration>
		</plugin>
		
	</plugins>
  </build>	

References

  1. Apache Maven WAR Plugin
  2. Apache Tomcat – Which version do I want?

About Author

author image
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

Subscribe
Notify of
7 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Siva
8 years ago

Even simpler: Add false to section in pom.xml. No need to add maven-war-plugin.

mkyong
8 years ago
Reply to  Siva

wow, thanks for your input, I didn’t know about that!

Dima
6 years ago

thanks!!

Mdhar
7 years ago

Thanks yong.

Armando Couto
8 years ago

very cool!!!

mkyong
8 years ago
Reply to  Armando Couto

Thanks

pavan yadav
3 years ago

Hello sir. I am Pavan. I have angular project, I want to build war of angular project and deploy it on wildfly.