[eclipse] 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?

This question is related to eclipse maven jakarta-ee m2eclipse

The answer is


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)

1

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

2

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

1


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


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:

  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)


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


Examples related to eclipse

How do I get the command-line for an Eclipse run configuration? My eclipse won't open, i download the bundle pack it keeps saying error log strange error in my Animation Drawable How to uninstall Eclipse? How to resolve Unable to load authentication plugin 'caching_sha2_password' issue Class has been compiled by a more recent version of the Java Environment Eclipse No tests found using JUnit 5 caused by NoClassDefFoundError for LauncherFactory How to downgrade Java from 9 to 8 on a MACOS. Eclipse is not running with Java 9 "The POM for ... is missing, no dependency information available" even though it exists in Maven Repository The origin server did not find a current representation for the target resource or is not willing to disclose that one exists. on deploying to tomcat

Examples related to maven

Maven dependencies are failing with a 501 error Why am I getting Unknown error in line 1 of pom.xml? Why am I getting "Received fatal alert: protocol_version" or "peer not authenticated" from Maven Central? How to resolve Unable to load authentication plugin 'caching_sha2_password' issue Unable to compile simple Java 10 / Java 11 project with Maven ERROR Source option 1.5 is no longer supported. Use 1.6 or later 'react-scripts' is not recognized as an internal or external command How to create a Java / Maven project that works in Visual Studio Code? "The POM for ... is missing, no dependency information available" even though it exists in Maven Repository Java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/exc/InvalidDefinitionException

Examples related to jakarta-ee

Java 11 package javax.xml.bind does not exist javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure The type java.io.ObjectInputStream cannot be resolved. It is indirectly referenced from required .class files Deploying Maven project throws java.util.zip.ZipException: invalid LOC header (bad signature) web.xml is missing and <failOnMissingWebXml> is set to true WELD-001408: Unsatisfied dependencies for type Customer with qualifiers @Default Name [jdbc/mydb] is not bound in this Context An internal error occurred during: "Updating Maven Project". java.lang.NullPointerException How to consume a SOAP web service in Java java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer

Examples related to m2eclipse

web.xml is missing and <failOnMissingWebXml> is set to true How to solve maven 2.6 resource plugin dependency? No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? An internal error occurred during: "Updating Maven Project". java.lang.NullPointerException An internal error occurred during: "Updating Maven Project". Unsupported IClasspathEntry kind=4 Maven "build path specifies execution environment J2SE-1.5", even though I changed it to 1.7 Failed to resolve version for org.apache.maven.archetypes Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies could not be resolved How to deal with missing src/test/java source folder in Android/Maven project? SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". error