Where is web.xml in Eclipse Dynamic Web Project

Eclipse

Eclipse Problem Overview


In Eclipse I clicked File->New->Dynamic Web Project and I am following a tutorial for Jersey that now wants me to go and change something in web.xml file...but I can't even find this file. What is it I am doing wrong?

enter image description here

Eclipse Solutions


Solution 1 - Eclipse

When you create a Dynamic Web Project you have the option to automatically create the web.xml file. If you don't mark that, the eclipse doesn't create it...

So, you have to add a new web.xml file in the WEB-INF folder.

To add a web.xml click on Next -> Next instead of Finish. You will find it on the final screen of the wizard.

Solution 2 - Eclipse

you can do it by Dynamic Web Project –> RightClick –> Java EE Tools –> Generate Deployment Descriptor Stub.

Solution 3 - Eclipse

If you don't see the web.xml file in WEB-INF folder,

enter image description here

**- Select Deployment Descriptor and right click on it.

  • Then select the Generate Deployment Descriptor Stub**

enter image description here

Finally you get web.xml file.

enter image description here

Solution 4 - Eclipse

When you open Eclipse you should click FileNewDynamic Web Project, and make sure you checked Generate web.xml, as described above.

If you have already created the project, you should go to the WebContent/WEB-INF folder, open web.xml, and put the following lines:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
    <display-name>Application Name </display-name>
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>
</web-app>

Solution 5 - Eclipse

Might be your project is not JEE nature, to do this Right Click -> Properties -> Project Facets and click Convert to facet and check dynamic web module and ok. Now you will be able to see Java EE Tools.

Solution 6 - Eclipse

Follow below steps to generate web.xml in Eclipse with existing Dynamic Web Project

  1. Right Click on Created Dynamic Web Project
  2. Mouse Over Java EE Tools
  3. Click on Generate Deployment Descriptor Stub
  4. Now you are able to see web.xml file on WEB-INF folder

enter image description here

Solution 7 - Eclipse

The web.xml file should be listed right below the last line in your screenshot and resides in WebContent/WEB-INF. If it is missing you might have missed to check the "Generate web.xml deployment descriptor" option on the third page of the Dynamic web project wizard.

Solution 8 - Eclipse

If you missed to check the "generate web.xml" option when creating a new project, no worries If it is a Dynamic Web Project in your project right click on "Deployment Descriptor:...." and Click on "Generate Deployment Descriptor Stub" this will create a minimal /webapp/WEB-INF/web.xml.

Solution 9 - Eclipse

For gradle / maven project you can use src/main/webapp/WEB-INF folder by default:

- main
- - java
- - resources
- - webapp
- - - META-INF
- - - - context.xml
- - - WEB-INF
- - - - web.xml

Solution 10 - Eclipse

If your deployment descriptor tab is disabled, then click on update libraries it will also do your work. It will create. Xml file in Web content

Solution 11 - Eclipse

I think you are creating a project in the wrong way,I am going to post here in step by step

Step 1: File>>New>>Project>>Web>>Dynamic Web Project

Step 2: Enter Project Name>>Next>>Next>>

Step 3: Check the checkbox for Generate web.xml deployment descriptor

Step 4: Finish

Please follow this way you will get you web.xml file under WEB-INF folder

Solution 12 - Eclipse

You can try this: right-click on the project and select Java EE Tools -> Generate Deployment Descriptor Stub. web.xml should be generated.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBohnView Question on Stackoverflow
Solution 1 - EclipseVitor BragaView Answer on Stackoverflow
Solution 2 - EclipseMarco Paulo OllivierView Answer on Stackoverflow
Solution 3 - EclipseGurusingheView Answer on Stackoverflow
Solution 4 - EclipseFillipe SilvaView Answer on Stackoverflow
Solution 5 - EclipsedeenView Answer on Stackoverflow
Solution 6 - EclipseNanda ThotaView Answer on Stackoverflow
Solution 7 - EclipseArneView Answer on Stackoverflow
Solution 8 - Eclipseuser1442999View Answer on Stackoverflow
Solution 9 - EclipseMikhail IonkinView Answer on Stackoverflow
Solution 10 - EclipseShruti PotdarView Answer on Stackoverflow
Solution 11 - EclipseRahulView Answer on Stackoverflow
Solution 12 - Eclipsemir pekiroView Answer on Stackoverflow