Maven – Failed to execute goal org.apache.maven.plugins: The specified web.xml file ‘D:\WEB-INF\web.xml’ does not exist

intellij-ideamavenmaven-3web.xml

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-
plugin:2.1.1:war (default-war) on project CRPS: The specified web.xml file
'D:\WEB-INF\web.xml' does not exist-> [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/MojoFailureException

NOTE: My project is under D:\MAVEN\
project folder is: D:\MAVEN\CRPS

When I click on install in intellij ideas this error is generated.
Why it happens?

Best Answer

as you can see the plugin is looking in D:\WEB-INF path to get the web.xml needed to do war packaging and that's obviously wrong place to look. you need to specify explicitly either by passing -Dmaven.war.webxml=..../WEB-INF/web.xml argument at runtime on the terminal or you could put the configuration in your pom by adding

 <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.3</version>
    <executions>
      <execution>
         <phase>package</phase>
         <configuration>
           <webXml>..../WEB-INF/web.xml</webXml>
         </configuration>
      </execution>
    </executions>
  </plugin>

Please note: you don't need to declare the absolute path, relative path to your project pom should be sufficient. Replace the dots with the correct path.

I am guessing your are not using the default maven war project layout and that is why you are getting this error. if you were, the plugin would have got the web.xml from src/main/webapp/WEB-INF/web.xml by default as per the below example.

  • pom.xml
  • src
    • main
      • java
      • resources
      • webapp
        • WEB-INF
          • web.xml
Related Topic