Java – XML error due to servlet file. The declaration of the element cannot be found, and the referenced file contains an error
I don't know why these mistakes happen. Someone can explain how I solve them –
> cvc-elt. 1: Element 'Web' not found_ 1: Declaration of 'web app'. > The reference file contains errors (jar: File: / C: / program files / eclipse / plugins / org. Eclipse. JST. Standard. Schemas_1.2.0. V201101142102. Jar! / dtdsandschemas / Web app_2_5. XSD) For more information, right-click the message in the issue view and select Show details
These are the two errors I face because I added a servlet by mistake. I intend to add a normal class file to my project Then these two errors began to show up, and even I deleted the servlet file This is my XML code (actually it's basic code) – because I haven't used a single servlet file yet, I only use JSP files
Still an XML file –
<?xml version="1.0" encoding="UTF-8"?>
<web_1: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_4.xsd"
xmlns:web_1="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>InitialD</display-name>
<web_1:welcome-file-list>
<web_1:welcome-file>index.html</web_1:welcome-file>
<web_1:welcome-file>index.htm</web_1:welcome-file>
<web_1:welcome-file>index.jsp</web_1:welcome-file>
<web_1:welcome-file>default.html</web_1:welcome-file>
<web_1:welcome-file>default.htm</web_1:welcome-file>
<web_1:welcome-file>default.jsp</web_1:welcome-file>
</web_1:welcome-file-list>
</web_1:web-app>
Solution
As mark and Saurabh said, from the web It is feasible to delete every instance of "web_1:" in the XML file At the same time, it is best to remove the reference to the schema "xmlns: web_1" A feasible fragment based on Saurabh problem is as follows:
<?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_4.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>InitialD</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
