Solved

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

Posted on 2004-04-28
4
7,782 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video discusses moving either the default database or any database to a new volume.

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now