"webxml attribute is required" error in Maven
Solution 1
It would be helpful if you can provide a code snippet of your maven-war-plugin.
Looks like the web.xml
is at right place, still you can try and give the location explicitly
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webXml>src\main\webapp\WEB-INF\web.xml</webXml>
</configuration>
</plugin>
Solution 2
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
This solution works for me (I was using 2.2 before). Also, I am using Java Based Configuration for Servlet 3.0 and no need to have web.xml file.
Solution 3
It works perfectly for me too.
<project>
.....
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webXml>WebContent\WEB-INF\web.xml</webXml>
</configuration>
</plugin>
</plugins>
</build>
</project>
Solution 4
This is because you have not included web.xml in your web project and trying to build war using maven. To resolve this error, you need to set the failOnMissingWebXml to false in pom.xml file.
For example:
<properties>
<failOnMissingWebXml>false</failOnMissingWebXml>
</properties>
Please see the blog for more details: https://ankurjain26.blogspot.in/2017/05/error-assembling-war-webxml-attribute.html
Solution 5
If you are migrating from XML-based to Java-based configuration and you have removed the need for web.xml by implementing WebApplicationInitializer, simply remove the requirement for the web.xml file to be present.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
...
</configuration>
user617966
Updated on January 23, 2021Comments
-
user617966 over 3 years
I am getting the following error:
Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode)
I have got
web.xml
in right place which isprojectname\src\main\webapp\WEB-INF\web.xml
What could be causing this?
-
Buffalo over 12 yearsWorked for me too, thanks. But what's the default location where Maven searches?
-
Ram over 11 yearsAbove works when facets are enabled and WebContent is the folder where web.xml goes in.
-
xverges about 10 yearsI just updated the maven war plugin from 2.1.1 to 2.4, and the need to make explicit the default location wen away.
-
erwineberhard over 8 yearsIt works, but the logs says now:
WEB-INF\web.xml already added, skipping
. That's weird, when I don't add this, I got the error. -
Adam over 8 yearsexactly! Couldn't figure it out until I saw I had just a slash at the beginning
<warSourceDirectory>\src\main\webapp</warSourceDirectory>
doesn't work! Not in v2.6 -
Prachi about 8 yearsSame as erwineberhard.
WEB-INF\web.xml already added, skipping
-
Paul Verest almost 8 yearssimilar answer was given before
-
shabby over 7 yearsand in netbeans you would: right click the project node> New > Other > Web > Standard Deployment Descriptor (web.xml).
-
Vic Torious over 7 yearsYou might want to update your answer for ItelliJ IDEA users - IntelliJ creates another project structure so it would be <webXml>web\WEB-INF\web.xml</webXml>
-
Bunny Joel over 6 yearstried your answer but still got the same error instead of that I did this "C:\Users\xxxx\Videos\maven-projects\my-project\src\webapp\WEB-INF" and worked good. I dont know what is the problem. Its my luck. Thank you
-
Giorgi Tsiklauri over 5 yearsjar and war are completely different stories. I think war is needed here, as the archive is getting deployed to web container and is not ran separately as a standalone jar application.
-
Eisenknurr about 5 yearsThe versions 3.x of that plugin now have failOnMissingWebXml default to
false
. So,<plugin> <artifactId>maven-war-plugin</artifactId> <version>3.2.3</version> </plugin>
should suffice. -
JGlass almost 5 yearsworked for me as I was and still am using jboss-web.xml - thanks!
-
foo over 4 yearsThis one gives context, where exactly the line needs to go.
-
blueSky about 4 yearsI have a project that does not have web.xml, and this worked for me. Maven build is successful.
-
Bhushan Karmarkar over 2 yearsI had to add <groupId>org.apache.maven.plugins</groupId> just before the artifactId, then it worked. Thanks