Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

eclipse not validating the struts.xml file

I installed the eclipse in my new p.c. and import my old project of struts2 in that and after importing the project i got a warning in struts.xml file i.e. "The file cannot be validated as there was a connection problem.". I replaced my jar files and doctype so many times but still it didn't work. I also found that eclipse is not showing me any error if i do something wrong in that file even when eclipse clean my project it takes a lot of time to clean struts.xml file

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE struts PUBLIC 
    "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
    "http://struts.apache.org/dtds/struts-2.3.dtd">

<struts>
 <package name="a" extends="struts-default">
 <action name="b" class="com.test">
   <result name="success">/success.jsp</result>
         <result name="error">/error.jsp</result>
      </action>

 </package>

</struts>

Please help me for this i am getting lots of difficulties...???

like image 696
Sahil Avatar asked May 15 '15 05:05

Sahil


2 Answers

Change Doctype to:

 <!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN"
    "/WEB-INF/dtds/struts-2.1.dtd">

and extract "struts-2.1.dtd" file from "struts2-core-2.1.8.1.jar" into dtds folder(CREATE NEW) inside WEB-INF folder.

like image 58
AsSiDe Avatar answered Oct 30 '22 20:10

AsSiDe


This happens when eclipse could not open the file, this happens sometimes for me when I have internet connection problems.

So make sure you have internet connection and you have not set any proxy which is not working and prevent eclipse to access the internet. You can open struts.xml and ctl+click on http://struts.apache.org/dtds/struts-2.3.dtd

If your problem is not solved, you can do as mentioned by @AsSide, copy the struts-2.3.dtd some where in your hard and change the struts.xml as below:

<!DOCTYPE struts SYSTEM "c://struts-2.3.dtd">

The DOCTYPE must be changed to SYSTEM instead of PUBLIC. Change the dtd location is not a good approach :)

like image 42
Alireza Fattahi Avatar answered Oct 30 '22 20:10

Alireza Fattahi