j2j
j2j

Reputation: 831

"mvn package" failure altough in Eclipse this maven web application runs

I got this error after doing "mvn clean package":

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1.1:w ar (default-war) on project webapp1: Error assembling WAR: webxml attribute is re quired (or pre-existing WEB-INF/web.xml if executing in update mode) -> [Help 1]

altough this maven web application runs smoothly via Eclipse (Run As / Run on Server).

Upvotes: 1

Views: 4517

Answers (1)

axtavt
axtavt

Reputation: 242786

By default maven-war-plugin expects webapp files to be in ${baseDir}/src/main/webapp folder. In your case these files can be located in another folder (Eclipse's Dynamic Web Project uses ${baseDir}/WebContent). If so, you need to move these files into default folder (it may require additional Eclipse configuration) or configure warSourceDirectory option of maven-war-plugin:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <configuration>
        <warSourceDirectory>WebContent</warSourceDirectory>
    </configuration>
</plugin>

Upvotes: 9

Related Questions