Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven error while building WAR package (web.xml missing..?)

Tags:

java

maven-2

While executing mvn install, I'm getting following error:

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

My web application structure tree is like that:

my-app
|-- pom.xml
|-- src
    |-- ...
    |-- WebContent
        |-- ...
        |-- META-INF
        |-- WEB-INF
            |-- classes
                |-- ...
            |-- lib
            |-- **web.xml**

My POM file looks like that:

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>masters.traffic</groupId>
  <artifactId>traffic_web</artifactId>
  <packaging>war</packaging>
  <name>traffic_web</name>
  <version>0.1.0</version>
  <build>
        <sourceDirectory>src</sourceDirectory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>                    
                </configuration>
            </plugin>
        </plugins>
  </build>

    ...
</project>

How to properly fix that issue ?

Regards

like image 667
jwaliszko Avatar asked Jun 28 '10 21:06

jwaliszko


1 Answers

I strongly recommend to use Maven's standard layout:

  • put the Java sources in src/main/java (and remove the sourceDirectory element)
  • put the Web application sources in src/main/webapp
  • remove the classes and lib directories under WEB-INF

Sure, you can customize the layout but this is IMO more troubles and useless efforts than benefits. Just follow the conventions.

like image 126
Pascal Thivent Avatar answered Oct 12 '22 15:10

Pascal Thivent