Solved

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

Posted on 2004-04-28
4
7,811 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
  • 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Apache server configuration 7 82
TreeSet comparator example 7 95
doubleChar java challenge 7 106
going to wrong jsp page 2 19
Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

786 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