Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"webxml attribute is required" error in Maven

Tags:

maven

war

I am getting the following error:

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

I have got web.xml in right place which is projectname\src\main\webapp\WEB-INF\web.xml

What could be causing this?

like image 314
user617966 Avatar asked Mar 18 '11 12:03

user617966


People also ask

Where is war file in Maven project?

Now, once we execute the mvn install command, the WAR file will be generated inside the target folder. Using the mvn:war:exploded command, we can generate the exploded WAR as a directory inside the target directory.

Where is Web XML Maven project?

Specifies where to find the web. xml file in the current Maven project, relative to the location of pom. xml . The default is src/main/webapp/WEB-INF/web.

What is Maven war plugin?

The WAR Plugin is responsible for collecting all artifact dependencies, classes and resources of the web application and packaging them into a web application archive.


2 Answers

It would be helpful if you can provide a code snippet of your maven-war-plugin. Looks like the web.xml is at right place, still you can try and give the location explicitly

<plugin>               <groupId>org.apache.maven.plugins</groupId>   <artifactId>maven-war-plugin</artifactId>   <configuration>     <webXml>src\main\webapp\WEB-INF\web.xml</webXml>           </configuration> </plugin> 
like image 68
Arpit Avatar answered Oct 04 '22 01:10

Arpit


<plugin>     <artifactId>maven-war-plugin</artifactId>     <version>2.4</version>     <configuration>         <failOnMissingWebXml>false</failOnMissingWebXml>     </configuration> </plugin> 

This solution works for me (I was using 2.2 before). Also, I am using Java Based Configuration for Servlet 3.0 and no need to have web.xml file.

like image 34
Sagar Avatar answered Oct 04 '22 01:10

Sagar