Servlet 3.0 requires the webxml attribute.

I get this error when trying to compile Vaadin WAR:

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

I know this error means that maven cannot find my web.xml, but the Vaadin Book says that web.xml is not required when using Servlet API 3.0 and Annotation @WebServlet in your user interface.

I collect my widgets in a separate profile (according to this guide), and it compiles fine when I rnu this profile. However, when I compile only a web project, I get the above error.

What gives?

Am I somehow redefining maven behavior? Vaadin did not even create the WEB-INF directory. I think I could create a WEB-INF folder and save the "ghost" web.xml there to keep maven happy, but that doesn't seem right.

Did I miss something?

Does anyone know a good solution for this?

+47
maven maven-plugin vaadin vaadin7
Aug 12 '13 at 12:07 on
source share
4 answers

By default, maven-war-plugin will fail if it cannot find web.xml, see here . If you create a Maven project using the latest archetype, you will get this parameter false:

  <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <configuration> <failOnMissingWebXml>false</failOnMissingWebXml> </configuration> </plugin> </plugins> </build> 

If you want to use web.xml instead of annotations, just create WEB-INF / web.xml and define a servlet there, see "Vaadin's Book" for detailed instructions.

+105
Aug 12 '13 at 12:24
source share

I landed here with a similar error, but using Eclise Luna (4.4) with Maven 3.0

I ended up with this:

  • move WebContent \ WEB-INF \ web.xml to src \ main \ webapp \ WEB-INF \ web.xml

  • Use <webXml> to indicate the location of web.xml

 <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.0</version> <configuration> <webXml>src\main\webapp\WEB-INF\web.xml</webXml> </configuration> </plugin> </plugins> <!-- we dont want the version to be part of the generated war file name --> <finalName>${project.artifactId}</finalName> </build> 
  1. Launch mvn package and see SUCCESS BUILD (for WAR)

Before that I tried to use the original path to the web.xml file

 <webXml>WebContent\WEB-INF\web.xml</webXml> 

But maven didn't pick up and better follow the maven folder structure

http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html

+3
Jun 03 '15 at 17:04
source share

Starting with version 3.0.0, maven-war-plugin works out of the box without web.xml .

Prior to Maven version 3.3.9, the war package is associated with an older version of maven-war-plugin , so you need to explicitly specify the version in pom.xml :

 <project> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>3.0.0</version> </plugin> </plugins> </build> </project> 

In earlier versions of maven-war-plugin , the default failOnMissingWebXml parameter failOnMissingWebXml set to true , which causes your problem. See Sergey Makarov for an answer on how to manually set the false parameter if you need to use an older version of the plugin.

+1
Oct 22 '16 at 16:09
source share

You may not follow the standard maven catalog layouts, as described here by the Maven catalog layout

0
May 28 '15 at 7:39
source share



All Articles