In Java Web application require web.xml file but develop web application using servlet 3.0 java based configuration is possible. Java file can take place of web.xml file. But during build application using maven, Maven will try to fine web.xml file in case of not able to find that web.xml file it throw error like webxml attribute is required. We can skip to find web.xml in maven plugin using bellow configuration.

[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.161 s
[INFO] Finished at: 2017-01-26T18:19:34+05:30
[INFO] Final Memory: 18M/237M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.4:war (default-war) on project spring-upload-file-servlet-3.0: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Process finished with exit code 1

Solution:

In Java web application when configuration based on java files at that need to disable to find web.xml in maven.

when maven try to build .war file at that time always try to find web.xml but in servlet 3.0 configuration we do not require web.xml file so need to disable it using following configuration:

Add following configuration in maven plugin :

<configuration>
    <failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>

like:

<plugins>
           <plugin>
               <artifactId>maven-war-plugin</artifactId>
               <version>2.4</version>
               <configuration>
                   <failOnMissingWebXml>false</failOnMissingWebXml>
               </configuration>
           </plugin>
           <plugin>
               <artifactId>maven-compiler-plugin</artifactId>
               <configuration>
                   <source>1.8</source>
                   <target>1.8</target>
               </configuration>
           </plugin>
       </plugins>

 


 

Was this post helpful?
Let us know, if you liked the post. Only in this way, we can improve us.
Yes
No

Leave a Reply

Your email address will not be published. Required fields are marked *