101

When building WAR package using Maven 2.1.1, I get this warning message:

[WARNING] Warning: selected war files include a WEB-INF/web.xml which will be ig
nored
(webxml attribute is missing from war task, or ignoreWebxml attribute is specifi
ed as 'true')

Is there a way to eliminate it? It doesn't fail the building process, but I just do not want to see it.

Alexander Farber
  • 21,519
  • 75
  • 241
  • 416
Sefler
  • 2,237
  • 5
  • 19
  • 29

3 Answers3

84

It seems to be fixed in current version of maven-war-plugin, so just specifying:

    <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.3</version>
    </plugin>

fixed it for me. (See the last answer (20/Sep/12 4:37 AM) from Anders Hammar on https://issues.apache.org/jira/browse/MWAR-248.)

David Balažic
  • 1,319
  • 1
  • 23
  • 50
anre
  • 3,617
  • 26
  • 33
  • 1
    Agreed. As of version 2.3, they finally took care of this annoying warning message for OCD programmers like me :) – Lenny Markus Nov 27 '12 at 03:24
  • Yes, this fixed it, however somehow `src/main/webapp/WEB-INF/web.xml` didn't for me using version 2.1.1 – Bizmarck Oct 02 '13 at 20:10
79

I got rid of this warning in maven 3.0.1 with the following build configuration (i believe perhaps web.xml is added to the project by other means, and should't be packaged by default):

<project>
    ...
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <packagingExcludes>WEB-INF/web.xml</packagingExcludes>
                </configuration>
            </plugin>
        </plugins>
    </build>
    ...
</project>
Vitaly Olegovitch
  • 3,509
  • 6
  • 33
  • 49
Andrei Amariei
  • 976
  • 7
  • 8
  • 21
    I found you can add this to the configuration to be sure web.xml makes it in. At this time it appears optional, but better safe than sorry. `src/main/webapp/WEB-INF/web.xml` – bhavanki Jul 21 '11 at 13:43
  • Including the project-relative path doesn't seem to work; however, the format in the answer does. – Mike Yockey Jan 23 '12 at 18:04
  • I'll try this. Within `` I also have `${package.final.name}`. What does this do? – Xonatron Feb 01 '12 at 17:10
  • 1
    I had to use 2.2 or the war will contain a default web.xml instead of the one I specify. 2.1.1 worked for a while, but not anymore. – Lost In Code Feb 22 '12 at 21:05
  • Like @shockwave suggested, I prefer this one : http://stackoverflow.com/a/5353693/880118 – TecHunter Jul 30 '12 at 14:32
  • 4
    I am down-voting this response, because while it does get rid of the error warning, it is the wrong and confusing thing to do! You should do what shockwave described or if you are happy with the default web.xml then don't write one yourself at all. – Ustaman Sangat Oct 17 '12 at 16:07
23

I've filed the following bug report regarding this issue: https://issues.apache.org/jira/browse/MWAR-248

David Balažic
  • 1,319
  • 1
  • 23
  • 50
Gili
  • 86,244
  • 97
  • 390
  • 689
  • This bug is reported as closed but I get this message in maven 3.0.4 on windows 7. Even after adding src/main/webapp/WEB-INF/web.xml to my pom.xml – simgineer Jul 09 '12 at 20:57
  • @simgineer, you should comment inside the bug report. If that doesn't help, consider opening a new bug report and linking to it from here. – Gili Jul 10 '12 at 15:20