0
votes

I am trying to create a new web project using eclipse

File-> new -> Dynamic web project

Next Next and Finish

Here i get the web.xml

and it shows me the following error

cvc-elt.1.a: Cannot find the declaration of element 'web-app'. (if i select 2.5 dynamic web module version)

Error while downloading 'http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd' to C: \Users\yg178f.lsp4xml\cache\http\java.sun.com\xml\ns\javaee\web-app_3_0.xsd. (if i select 3.0 dynamic web module version)

Here is my web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>Struts2Demo</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>
1
Hi, am getting same error. did you find any solution to this? thanks.user1447718
I dont remember exactly, but what I can remember is, that I downloaded the XSD and kept it inside WEB-INF and rather than giving URLs, I gave the path the XSD (Though relative path) and that solved my problem at that time. it has been quite some time I faced this problem, so I am not sure if this was the exact solution I got at that time.Yogesh Gandhi

1 Answers

0
votes

I took this web.xml from here, and got rid of the issues, by removing all the URLs:

  <?xml version="1.0" encoding="UTF-8"?> 
    <web-app> 
      <filter> 
      <filter-name>struts2</filter-name> 
       <filter-class> 
        org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter 
       </filter-class> 
      </filter> 
      <filter-mapping> 
       <filter-name>struts2</filter-name> 
        <url-pattern>/*</url-pattern> 
      </filter-mapping> 
    </web-app>