score:196

Accepted answer

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

score:-1

create web-inf folder in src/webapp, and include web.xml page inside the web-inf folder then

score:-1

right click on the project, go to maven -> update project... , then check the force update of snapshots/releases , then click ok. it's done!

score:0

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

score:0

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

1

score:0

select your project and select the "deployment descriptor" option and then choose "generate deployment descriptor stub"

score:0

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

score:0

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.

score:0

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.

score:1

do this:

go and right click on deployment descriptor and click generate deployment descriptor stub.

score:1

you need to add this tags to your pom.xml

 <properties>
    <failonmissingwebxml>false</failonmissingwebxml>
</properties>

score:1

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.

score:2

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."

score:2

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.

score:3

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.

score:11

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.)

score:16

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.

score:19

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

score:20

you can also do this which is less verbose

<properties>
    <failonmissingwebxml>false</failonmissingwebxml>
</properties>

score:34

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)

score:409

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>

Related Query

More Query from same tag