Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't get struts.xml to connect to struts-2.0.dtd

I am working with Struts 2 in Rational Application Developer (RAD) v 7.5.3.

I keep getting the following warning in my struts.xml file:

The file cannot be validated as the XML Schema http://struts.apache.org/dtds/struts-2.0.dtd that is specified as describing the syntax of the file cannot be located.

I have the struts.xml file in the src folder.

The Struts 2 jar file I'm using is struts2-core-2.3.16.3.jar.

I have the following in the struts.xml file:

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

I've tried changing the struts-2.0.dtd to struts-2.3.dtd, so that it would look like this:

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

(When I first posted this question, I forgot to change the "DTD Struts Configuration 2.0" to "DTD Struts Configuration 2.3" in the second example above. I corrected it but still encountered the problem afterwards.

Thanks Roman C for pointing that out though.)

But it is still unable to connect for some reason.

I put those Struts URLs in my browser to see if my browser could access them, and they could. When you access the URLs in the browser, the browser prompts you to download the file.

I can run my sample Struts 2 app, but this validation warning won't go away.

What might be causing it and how to get rid of the warning?

Update:

I have tried

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

And that worked. Obviously, I got validation errors because my workspace is using Struts 2, not Struts 1. But the URL worked.

I have tried

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

And it didn't work. I even tried

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

And it still didn't work.

I'm using Struts 2 vs. 2.3.16.3.

For some reason, it doesn't like the first string in the !DOCTYPE tag.

If the first string in the !DOCTYPE tag is anything other than:

"-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"

Than the URL in the second string in the !DOCTYPE tag is inaccessible no matter what it is and cannot be read in RAD.

like image 880
Charles Carrington Avatar asked Oct 19 '25 06:10

Charles Carrington


1 Answers

For some systems where connection to the outside world is restricted by firewall or the site is temporary unavailable you can modify the location of DTD in the DOCTYPE declaration. You can extract DTD from the one of the core jars and place it for example under WEB-INF/dtds and modify DOCTYPE declaration in the following way

<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
    "/WEB-INF/dtds/struts-2.3.dtd">
like image 187
Roman C Avatar answered Oct 21 '25 22:10

Roman C



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!