Yogesh Doke
Yogesh Doke

Reputation: 1726

web.xml is missing and <failOnMissingWebXml> is set to true

Consider:

Enter image description here

When I create a simple Maven project in Eclipse I am getting this error:

web.xml is missing and <failOnMissingWebXml> is set to true

How can I fix this problem?

Upvotes: 155

Views: 289213

Answers (22)

Syed Aaqib Hussain
Syed Aaqib Hussain

Reputation: 139

Please add the following XML Code before the closing tag </ project > in POM.XML

<properties>
    <failOnMissingWebXml>false</failOnMissingWebXml>
</properties>

This should solve your error for the missing WEB.XML file.

Upvotes: 1

Park JongBum
Park JongBum

Reputation: 1403

If you were using Eclipse, you can do this graphically as follows:

  1. Find "Overview" tab at the bottom of editor pane
  2. Open "Properties" line button
  3. Click Create... button on the right
  4. Input <Name, Value> pair
  5. Press OK enter image description here

Upvotes: 0

Meriem Bader
Meriem Bader

Reputation: 173

you need to add this tags to your pom.xml

 <properties>
    <failOnMissingWebXml>false</failOnMissingWebXml>
</properties>

Upvotes: 1

user9999
user9999

Reputation: 154

My project had nothing to do with war, but the same error. I had to remove project from eclipse, delete all eclipse files from the project folder and reimport maven project.

Upvotes: 0

Vraj Patel
Vraj Patel

Reputation: 1

Right click on the project --> New --> Other --> Standard Deployment Descriptor(web.xml)

1

then press Next it will create WEB-INF folder with a web.xml file inside.

2

That's it done.

Upvotes: 0

Lotchi Dagbo
Lotchi Dagbo

Reputation: 1

The step of : Select your project and select the "Deployment Descriptor" option and then choose "Generate Deployment Descriptor stub" works fine. The issue is that it is not always the case that we need web.xml, so it is best to append false to pom.xml

Upvotes: 0

Jo&#227;o V.
Jo&#227;o V.

Reputation: 61

Right click on the project, go to Maven -> Update Project... , then check the Force Update of Snapshots/Releases , then click Ok. It's done!

Upvotes: -1

Christina Vimala
Christina Vimala

Reputation: 1

Select your project and select the "Deployment Descriptor" option and then choose "Generate Deployment Descriptor stub"

Upvotes: 0

Saurav
Saurav

Reputation: 392

For Project with web.xml present Project-->Properties-->Deployment Assembly,where you can add Folder src/main/webapp. Save change. Clean the project to get going.

For Project with web.xml not present Set failOnMissingWebXml to false in pom.xml under properties tag.

Upvotes: 2

jun gao
jun gao

Reputation: 11

Remove files from -web/.setting&-admin/.setting

1

Upvotes: 0

basavaraj Marapur
basavaraj Marapur

Reputation: 1

Create WEB-INF folder in src/webapp, and include web.xml page inside the WEB-INF folder then

Upvotes: -1

Eclipse recognizes incorrect default webapp directory. Therefore we should set clearly it by maven-war-plugin.

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-war-plugin</artifactId>
      <version>3.0.0</version>
      <configuration>
        <webappDirectory>src/main/webapp</webappDirectory>
      </configuration>
    </plugin>
  </plugins>
</build>

Once saving this setting, the error will never occour if removed it. (I cannot explain why.)

Upvotes: 11

milan.latinovic
milan.latinovic

Reputation: 2407

If you use Spring Tool Suite, option for Generate Deployment Descriptor Stub is moved under Java EE Tools, so you:

  1. Right click on your project
  2. Select Java EE Tools
  3. Select Generate Deployment Descriptor Stub option

This will create web.xml file inside src/main/webapp/WEB-INF/ folder, and of course remove error from Maven's pom.xml file.

enter image description here

Upvotes: 20

Martijn Burger
Martijn Burger

Reputation: 7543

This is a maven error. It says that it is expecting a web.xml file in your project because it is a web application, as indicated by <packaging>war</packaging>. However, for recent web applications a web.xml file is totally optional. Maven needs to catch up to this convention. Add this to your maven pom.xml to let maven catch up and you don't need to add a useless web.xml to your project:

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

This is a better solution than adding an empty web.xml because this way your final product stays clean, your are just changing your build parameters.

For more current versions of maven you can also use the shorter version:

<properties>
    <failOnMissingWebXml>false</failOnMissingWebXml>
</properties>

Upvotes: 414

The Gilbert Arenas Dagger
The Gilbert Arenas Dagger

Reputation: 12741

I encountered this issue in eclipse only, everything worked fine in Maven command line, and my web.xml file existed. It was a mature project (already deployed out in production) that was impacted. My problem was tied to the eclipse metadata. There was an issue with one of the files in my .settings/ folder, specifically org.eclipse.wst.common.component had been changed. I was able to restore this file to its prior version, which resolved the issue in my case.

Note that Yuci's answer did not work for me, when I tried to click on Deployment Assembly in the eclipse properties, I got an error that said "the currently displayed page contains invalid values."

Upvotes: 2

Wojciechu
Wojciechu

Reputation: 3910

You can do it also like this:

  1. Right click on Deployment Descriptor in Project Explorer.
  2. Select Generate Deployment Descriptor Stub.

It will generate WEB-INF folder in src/main/webapp and an web.xml in it.

enter image description here

Upvotes: 199

Boris Treukhov
Boris Treukhov

Reputation: 17774

I had the same problem, even though I had 'src/main/webapp/WEB-INF/' folder with correct web.xml.

The problem disappeared after I recreated (maven->eclipse) configuration with Maven build.. I executed mvn eclipse:clean eclipse:eclipse

And then I used Maven -> Update Project to add (eclipse->maven) plugin specific options.

Upvotes: 3

liam mooney
liam mooney

Reputation: 301

You can also do this which is less verbose

<properties>
    <failOnMissingWebXml>false</failOnMissingWebXml>
</properties>

Upvotes: 20

Nuno Marques
Nuno Marques

Reputation: 19

Do this:

Go and right click on Deployment Descriptor and click Generate Deployment Descriptor Stub.

Upvotes: 0

cforce
cforce

Reputation: 11

It doesn't make sense to create a web.xml just elcipse wants it, even there is no need. This is the case if you have servlet conatiner embedded or living without xml cfg like spring-boot does. The you just diable JavaEE (useless stuff) in eclipse on project level or global

Eclipse/STS>Windows>Preferences>JavaEE>Doclet>Webdoclet> "uncheck" DeploymentDescriptor > OK

Upvotes: -1

Yuci
Yuci

Reputation: 30089

If you already have web.xml under /src/main/webapp/WEB-INF but you still get error "web.xml is missing and is set to true", you could check if you have included /src/main/webapp in your project source.

Here are the steps you can follow:

  1. You can check this by right clicking your project, and open its Properties dialogue, and then "Deployment Assembly", where you can add Folder /src/main/webapp. Save the setting, and then,
  2. Go to Eclipse menu Project -> Clean... and clean the project, and the error should go away.

(I verified this with Eclipse Mars)

Upvotes: 34

Tung
Tung

Reputation: 1671

I have the same problem. After studying and googling, I have resolved my problem:

Right click on the project folder, go to Java EE Tools, select Generate Deployment Descriptor Stub. This will create web.xml in the folder src/main/webapp/WEB-INF.

Upvotes: 17

Related Questions