web.xml is Missing and <failOnMissingWebXml> is set to true

Asked

Viewed 8,541 times

4

inserir a descrição da imagem aqui

Usually the question is, have you ever deployed in the project? The answer is yes.

I right clicked on the project I went to Maven after Update project, it is procedure that I always do my projects and this time is giving problem.

web xml.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>br.com.comercial.adm</groupId>
    <artifactId>ComercialADM</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>war</packaging>



    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>




        <!-- PrimeFaces (biblioteca de componentes) -->
        <dependency>
            <groupId>org.primefaces</groupId>
            <artifactId>primefaces</artifactId>
            <version>3.5</version>
            <scope>compile</scope>
        </dependency>

        <!-- Mojarra (implementacao do JSF) -->
        <dependency>
            <groupId>org.glassfish</groupId>
            <artifactId>javax.faces</artifactId>
            <version>2.1.21</version>
            <scope>compile</scope>
        </dependency>




    </dependencies>



    <build>
        <finalName>ComercialADM</finalName>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <repositories>
        <repository>
            <id>prime-repo</id>
            <name>PrimeFaces Maven Repository</name>
            <url>http://repository.primefaces.org</url>
            <layout>default</layout>
        </repository>
    </repositories>




</project>

2 answers

9


The error is because since Packaging was set to War, Maven recognizes by default the configuration of the need for a web.xml, given the version of Servlet you are using, if it is older than version 3.0, web.xml is required.

If the current version, one way to eliminate this error is with the Maven-War-plugin, in its configuration, set the failOnMissingWebXml as false.

<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>

https://maven.apache.org/plugins/maven-war-plugin/war-mojo.html#failOnMissingWebXml

2

Maybe it is useful for someone else (5 years after the answer accepted) a second alternative...

Using the Version 4.0 and Servlet 4.0.1 template here, it was enough to include <failOnMissingWebXml>false</failOnMissingWebXml> in <properties> for Eclipse not to complain, without needing to depend on the plugin maven-war-plugin.

pom.xml (relevant excerpt):

    <properties>
        <failOnMissingWebXml>false</failOnMissingWebXml>
        <!-- outras properties -->
    </properties>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.