[Solved-4 Solutions] “webxml attribute is required” error in Maven



Error Description:

  • We get the following error:

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

  • We have got web.xml in right place which is projectname\src\main\webapp\WEB-INF\web.xml
  • What could be causing this?

Solution 1:

  • The value of my webXml tag need to look like this in order to work:
<webXml>${project.basedir}\src\main\webapp\WEB-INF\web.xml</webXml> 
click below button to copy the code. By - maven tutorial - team

Solution 2:

  • If we are migrating from XML-based to Java-based configuration and we have removed the need for web.xml by implementing WebApplicationInitializer, we need to 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>
click below button to copy the code. By - maven tutorial - team

Solution 3:

  • A quick fix is to create a src/main/java and a src/main/webapp directory (and other directories if we need them) and just move the files.

Solution 4:

  • Make a new folder named WEB-INF under src/main/webbapp then
  • Right Click on the Project -> Java EE Tools -> Generate Deployment Descriptor Stub
  • This should generate the web.xml.

Related Searches to “webxml attribute is required” error in Maven