web.xml is missing and is set to true – web.xml is there and can’t edit deployment assembly

This is an error from maven, it is saying that is expecting a web.xml file because the project is defined as a web project on pom.xml through <packaging>war</packaging>. As in some web application web.xml is optional, instead creating an empty web.xml you can overwrite the default value from the property failOnMissingWebXml on maven-war-plugin adding the following values on your pom.xml

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

If you need a web.xml file on your project, you can create it like this:

Maven WAR project default structure

web.xml content:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    version="2.5">
    <display-name>stackoverflow</display-name>
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>
</web-app>

To avoid some problems with IDE, try to run mvn clean install from prompt. If it works, you should check IDE files on the project (e.g. Eclipse has .project .setting and .classpath files who has some information that can be generating the error).

Leave a Comment