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
.
Right click on the project --> New --> Other --> Standard Deployment Descriptor(web.xml)
then press Next it will create WEB-INF
folder with a web.xml
file inside.
That's it done.
you need to add this tags to your pom.xml
<properties>
<failOnMissingWebXml>false</failOnMissingWebXml>
</properties>
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.
Remove files from -web/.setting&-admin/.setting
If you use Spring Tool Suite, option for Generate Deployment Descriptor Stub is moved under Java EE Tools, so you:
This will create web.xml file inside src/main/webapp/WEB-INF/ folder, and of course remove error from Maven's pom.xml file.
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.
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:
(I verified this with Eclipse Mars)
Select your project and select the "Deployment Descriptor" option and then choose "Generate Deployment Descriptor stub"
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."
You can also do this which is less verbose
<properties>
<failOnMissingWebXml>false</failOnMissingWebXml>
</properties>
Do this:
Go and right click on Deployment Descriptor and click Generate Deployment Descriptor Stub.
Create WEB-INF folder in src/webapp, and include web.xml page inside the WEB-INF folder then
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
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>
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.
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.)
Right click on the project, go to Maven -> Update Project... , then check the Force Update of Snapshots/Releases , then click Ok. It's done!
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
Source: Stackoverflow.com