Solved

Parsing exception with <global-exceptions> in struts-config.xml

Posted on 2004-04-28
4
7,873 Views
Last Modified: 2011-08-20
Hi Whenever i Add the global-exception handler to struts-config.xml,the application deployment gives a parsing exception.Though the application seems to be working normal i would like to know why that parsing exception is thrown

I have the following declaration in struts-config.xml
<global-exceptions>
    <exception
      key="qams.exception"
      type="java.lang.Exception"
      handler="com.qas.exceptions.QAMSExceptionHandler"/>
</global-exceptions>

The exception thrown during deployment of application is(the first few lines only)

[ERROR] Digester - -Parse Error at line 701 column 17: The content of element type "struts-config" must match "(data-sources?,form-beans?,global-exceptions?,global-forwards?,action-mappings?,controller?,message-resources*,plug-in*)". <org.xml.sax.SAXParseException: The content of element type "struts-config" must match "(data-sources?,form-beans?,global-exceptions?,global-forwards?,action-mappings?,controller?,message-resources*,plug-in*)".>org.xml.sax.SAXParseException: The
content of element type "struts-config" must match "(data-sources?,form-beans?,global-exceptions?,global-forwards?,action-mappings?,controller?,message-resource
s*,plug-in*)".
        at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Un
known Source)
        at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
        at org.apache.xerces.impl.dtd.XMLDTDValidator.handleEndElement(Unknown S
ource)
        at org.apache.xerces.impl.dtd.XMLDTDValidator.endElement(Unknown Source)

        at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknow
n Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContent
Dispatcher.dispatch(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Un
known Source)


Any suggestions please
Regards
Dheeraj Bhat
0
Comment
Question by:dheerajbhat
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 7

Expert Comment

by:searlas
ID: 10937669
Does it appear in the correct place in your struts-config?

After form-beans and before global-forwards (or before action-mappings if you have no global-forwards)
0
 
LVL 7

Accepted Solution

by:
searlas earned 250 total points
ID: 10937788
To empahsize, the contents of the struts-config must appear in the correct order:

data-sources?,
form-beans?,
global-exceptions?,
global-forwards?,
action-mappings?,
controller?,
message-resources*,
plug-in*

(? means an item appears 0 or once, * means it can appear any number of times - including 0)
0
 
LVL 1

Author Comment

by:dheerajbhat
ID: 10947149
Hi,
  That worked.
   But is there any documentation which mentions that.I wasnt aware of that there were some ordering of elements in struts-config.Can you specify the URL of the document.

Regards
Dheeraj Bhat
0
 
LVL 7

Expert Comment

by:searlas
ID: 10947249
Sure... you should have a DOCTYPE in your struts-config.xml, as below:

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


The struts-config.xml must conform to the specification given in the dtd file:
http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd

This is common for XML files, and is worth learning about (a decent XML editor would automatically download the mentioned DTD and highlight any errors for you...)
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
First of all let me say that the only language that I speak is English, but in answering questions here I often come across people whose English skills are not the best and I’d like to be able to communicate better with them, and the following descr…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question