Struts: How to validate DTDs locally

Local DTD Validation

We had internet issues and noticed that the application failed to startup. On closer inspection it was validating the tiles xml config against a DTD, but instead of using the local copy bundled with Struts it was going out to the internet.

It is also required that for production deployments, all network activity should be restricted. DTD validation should be done locally.

javax.servlet.UnavailableException: IO Error while parsing file '/WEB-INF/tiles-defs.xml'. Connection reset
	at org.apache.struts.action.ActionServlet.init(
	at javax.servlet.GenericServlet.init(
	at org.apache.catalina.core.StandardWrapper.loadServlet(
	at org.apache.catalina.core.StandardWrapper.load(
	at org.apache.catalina.core.StandardContext.loadOnStartup(
	at org.apache.catalina.core.StandardContext.start(
	at org.apache.catalina.core.ContainerBase.addChildInternal(

To fix this, the public identifier in the DTD header should match exactly what is inside your struts.jar.

In this case we incorrectly had:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tiles-definitions PUBLIC
       "-//Apache Software Foundation//DTD Tiles Configuration//EN"

This had to be changed to:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tiles-definitions PUBLIC
       "-//Apache Software Foundation//DTD Tiles Configuration 1.1//EN"

Note that the "1.1" was missing. To find the correct public identifier, find the corresponding DTD in the struts.jar and ensure it matches. In struts-1.2.9.jar, look inside org/apache/struts/resources/tiles-config_1_1.dtd

Published: Sunday, 1 April 2012