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?
12 Answers
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.
-
166I think you can right-click the project and select "Java EE Tools" -> "Generate Deployment Descriptor Stub". It made me a web.xml– TommyOct 8, 2012 at 7:46
-
1This should be marked as the right answer for those who forgot to check the option. Dec 10, 2015 at 18:19
you can do it by Dynamic Web Project –> RightClick –> Java EE Tools –> Generate Deployment Descriptor Stub.
If you don't see the web.xml file in WEB-INF folder,
- Select Deployment Descriptor and right click on it.
- Then select the Generate Deployment Descriptor Stub
Finally you get web.xml file.
When you open Eclipse you should click File → New → Dynamic 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>
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.
Follow below steps to generate web.xml in Eclipse with existing Dynamic Web Project
- Right Click on Created Dynamic Web Project
- Mouse Over Java EE Tools
- Click on Generate Deployment Descriptor Stub
- Now you are able to see web.xml file on WEB-INF folder
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.
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.
-
how to edit web.xml because eclipse generates 404 when i run project web-inf resource not found Jun 29, 2014 at 17:28
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
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
-
I was facing this issue. Generate Deployment Descriptor Stub option was disabled. On updating library, an web.xml file was created. Jan 1 at 7:16
You can try this: right-click on the project and select Java EE Tools
-> Generate Deployment Descriptor Stub
. web.xml should be generated.
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