Skip to content

How to resolve Error assembling WAR webxml attribute is required exception when building springboot wars

1. The purpose of this post

When building a Spring Boot application as a WAR file, you might encounter the following exception:

Terminal window
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war (default-war) on project sbjt1: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode) -> [Help 1]

This post will guide you on how to resolve this issue.

2. Environments

  • Spring Boot

3. The solution

3.1 The original pom.xml

Before resolving the issue, let’s look at the original pom.xml:

pom.xml
<build>
<finalName>${artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<classifier>exec</classifier>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

3.2 The correct pom.xml

To resolve the issue, you need to add the maven-war-plugin to your pom.xml:

pom.xml
<build>
<finalName>${artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<classifier>exec</classifier>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</build>
pom.xml
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>

4. Summary

When building a Spring Boot application as a WAR file, the “webxml attribute is required” error often occurs due to missing or incorrect configuration in the pom.xml file. By adding the maven-war-plugin and ensuring its version is compatible, you can resolve this issue. Always verify the plugin version and configuration to avoid similar errors in the future.

Final Words + More Resources

My intention with this article was to help others who might be considering solving such a problem. So I hope that’s been the case here. If you still have any questions, don’t hesitate to ask me by email: Email me

Here are also the most important links from this article along with some further resources that will help you in this scope:

Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!