0

I am creating a nested project in which I have services and web-apps. For services and web-apps root pom I have given packaging as pom but for services subproject, I gave packaging type as jar and for web-apps subproject, I have given packaging type as war. I have been getting below error for web-apps. It says web.xml is required to build. I am just creating an empty project but why does this error come up?

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

1 Answers1

0

No , it is not a must to have web.xml. The error message is most probably that you are using an old version of maven-war-plugin. You can turn this checking off by setting failOnMissingWebXml to false :

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

Or you can consider to upgrade the maven-war-plugin to the latest version . Since 3.0 , it already changed the default value of failOnMissingWebXml to false.

Ken Chan
  • 84,777
  • 26
  • 143
  • 172
  • Thanks it did work. But can I add it under the main project..for now under the main project there is a webapps project and I have changed pom for webapps project? – Kovoor Prajwal Aug 25 '19 at 13:17
  • Also, I didn't include any maven-war-plugin till before..so how did it pick up the version for maven-war-plugin? was it using maven war plugin from maven version of the project? – Kovoor Prajwal Aug 25 '19 at 13:19
  • for the default version of maven plugin used , please refer to https://stackoverflow.com/questions/21128372/how-does-maven-resolve-plugin-versions – Ken Chan Aug 25 '19 at 14:30
  • is the main project that you mention is the parent pom ? if yes , you can define at here , the child maven poroject will inhirent the setting from the parent parent – Ken Chan Aug 25 '19 at 14:32
  • Can we add it in parent's parent pom even? – Kovoor Prajwal Aug 25 '19 at 16:27
  • @Kovoor Prajwal yes you can – Ken Chan Aug 26 '19 at 02:00
  • How will web.xml get generated? Can i use ecllipse ->J2EETools -> generate deployment descriptor to generate it? Whats the best way? – Kovoor Prajwal Aug 26 '19 at 04:54
  • i usually add it manually by myself , just drop it into `src/main/webapp/WEB-INF/web.xml` – Ken Chan Aug 26 '19 at 04:57