Struts – <global-exceptions> xml parsing exception
Problem
A <global-exceptions> exception handler example in struts-config.xml.
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_3.dtd"> <struts-config> <global-exceptions> <exception key="error.io.key" type="java.io.IOException" path="/error.jsp" /> </global-exceptions> <form-beans> <form-bean name="dynaUserForm" type="org.apache.struts.action.DynaActionForm"> <form-property name="username" type="java.lang.String"/> </form-bean> </form-beans> <action-mappings> //... </action-mappings> </struts-config>
During deployment, org.apache.commons.digester.Digester error is prompt.
19 April 2010 6:50:13 PM org.apache.commons.digester.Digester error SEVERE: Parse Error at line 52 column 17: The content of element type "struts-config" must match "(display-name?,description?,form-beans?, global-exceptions?,global-forwards?,action-mappings?,controller?, message-resources*,plug-in*)".
The <global-exceptions> syntax is absolutely correct, did you spot the error?
Solution
The elements of the struts-config.xml “MUST” appear in the correct order. See the error message again :
"struts-config" must match display-name?, description?, form-beans?, global-exceptions?, global-forwards?, action-mappings?, controller?, message-resources*, plug-in*
The <form-beans> have to appear before <global-exceptions>. You need to change your struts-config.xml to the following order :
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_3.dtd"> <struts-config> <form-beans> <form-bean name="dynaUserForm" type="org.apache.struts.action.DynaActionForm"> <form-property name="username" type="java.lang.String"/> </form-bean> </form-beans> <global-exceptions> <exception key="error.io.key" type="java.io.IOException" path="/error.jsp" /> </global-exceptions> <action-mappings> //... </action-mappings> </struts-config>







Thanks a lot for this post , i was breaking my head seeing this error message in struts-config and i could nt spot this order thing !!!!! i tried so many things but nothing worked. your posts are life saver for us .Thanks again – Ajith
[...] wi?cej: Struts – <global-exceptions> xml parsing exception | Struts Tags: exception-handler Comments RSS [...]