Metawerx Java Hosting Small Logo

Debug Your App - org.xml.sax.SAXException

This page shows errors where an org.xml.sax.SAXException exception is thrown and how to fix them.

Table of Contents

org.xml.sax.SAXException: Internal Error: File /javax/servlet/resources/web-app_2_3.dtd not found


or

org.xml.sax.SAXException: Internal Error: File /javax/servlet/resources/web-app_2_2.dtd not found

Submitter: Neale Rudd
exception

org.apache.jasper.JasperException: XML parsing error on file /WEB-INF/web.xml
	org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:453)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
	...

org.apache.jasper.JasperException: XML parsing error on file /WEB-INF/web.xml
	org.apache.jasper.xmlparser.ParserUtils.parseXMLDocument(ParserUtils.java:107)
	org.apache.jasper.compiler.JspConfig.processWebDotXml(JspConfig.java:76)
	org.apache.jasper.compiler.JspConfig.init(JspConfig.java:197)
	...
	
org.xml.sax.SAXException: Internal Error: File /javax/servlet/resources/web-app_2_3.dtd not found
	org.apache.jasper.xmlparser.MyEntityResolver.resolveEntity(ParserUtils.java:205)
	...

This mainly occurs on Tomcat versions 5.5.9 and above, on some applications only. Cause still unkown (the server could just get the DTD from java.sun.com...). For an easy fix, just change the top of your web.xml file from:

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
to the standard XMLSchema format for Servlets 2.4:
<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
     version="2.4">

org.xml.sax.SAXParseException: The content of element type "web-app" must match ...

Submitter: Neale Rudd
org.xml.sax.SAXParseException: The content of element type "web-app" must match "(icon?,display-name?,description?,distributable?,context-param*,filter*,filter-mapping*,listener*,servlet*,servlet-mapping*,session-config?,mime-mapping*,welcome-file-list?,error-page*,taglib*,resource-env-ref*,resource-ref*,security-constraint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-local-ref*)".
	at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown 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 Source)
	at org.apache.xerces.impl.dtd.XMLDTDValidator.endElement(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	...

This is an XML validation error, indicating a problem in your web.xml file, according to the XML DTD specified at the top of the file.

Look for a line just above, that says something like ...

SEVERE: Parse Error at line 40 column 11: The content of element type "web-app" must match "(icon?,display-name?,description?,distributable?,context-param*,filter*,filter-mapping*,listener*,servlet*,servlet-mapping*,session-config?,mime-mapping*,welcome-file-list?,error-page*,taglib*,resource-env-ref*,resource-ref*,security-constraint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-local-ref*)".
This indicates the location of the error. Remove, comment out, or fix the erroneous area, then redeploy the app.

org.xml.sax.SAXParseException: The element type "someElement" must be terminated by the matching end-tag "</someElement>"

Submitter: Neale Rudd
SEVERE: Parse Fatal Error at line 15 column 24: The element type "someElement" must be terminated by the matching end-tag "</someElement>".
or
SEVERE: Servlet.service() for servlet jsp threw exception
followed by:
org.xml.sax.SAXParseException: The element type "someElement" must be terminated by the matching end-tag "</someElement>".
	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)

This error occurs when an XML file (such as web.xml or a TLD file) has a mismatched opening and closing tag.

With TLD files, check the log file for another exception directly above this one (a org.apache.jasper.JasperException: XML parsing error), which specifies the TLD file name, line and column. Note that a custom error page may consume this first exception and make it harder to find unless you are logging or mailing the exception trace from that custom error page. In this case, check all TLD files for the tag mentioned in the exception (eg: "someElement" in the above example). If you still cannot identify the file and line, restart the application.

Usually the line and filename show the first time this error appears only, with the message "SEVERE: Parse Fatal Error at line 15 column 24". After that, it just shows "SEVERE: Servlet.service() for servlet jsp threw exception" each time.

org.xml.sax.SAXParseException: The content of element type "redirect" must match "EMPTY".

Submitter: Neale Rudd
May 29, 2007 12:18:17 AM org.apache.commons.digester.Digester error
SEVERE: Parse Error at line 17 column 38: The content of element type "redirect" must match "EMPTY".
org.xml.sax.SAXParseException: The content of element type "redirect" must match "EMPTY".
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)
        at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384)
        at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)
        at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleEndElement(XMLDTDValidator.java:2009)
        at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.endElement(XMLDTDValidator.java:901)
		...
This error is caused by an error in your faces-config.xml, which is the JSF (Java Server Faces) config file. You may be using a value between bounded redirect tags, such as <redirect>http://somesite</redirect>, which is not valid according to the DTD. The redirect tag should be written as a single bounded tag (ie: <redirect />), as in the following example:
<faces-config>
	<!-- Navigation rules -->
	<navigation-rule>
		<description>List of games</description>
		<from-view-id>/listGames.jsp</from-view-id>
		<navigation-case>
			<from-outcome>editGame</from-outcome>
			<to-view-id>/editGame.jsp</to-view-id>
		</navigation-case>
	</navigation-rule>
	<navigation-rule>
		<description>Add or edit a game</description>
		<from-view-id>/editGame.jsp</from-view-id>
		<navigation-case>
			<from-outcome>listGames</from-outcome>
			<to-view-id>/listGames.jsp</to-view-id>
			<redirect />
		</navigation-case>
	</navigation-rule>
</faces-config>

From the JSF documentation: The "redirect" element indicates that navigation to the specified "to-view-id" should be accomplished by performing an HTTP redirect rather than the usual ViewHandler mechanisms.

org.xml.sax.SAXParseException: The string "--" is not permitted within comments.

Submitter: Neale Rudd
SEVERE: Parse Fatal Error at line 198 column 3: The string "--" is not permitted within comments.
org.xml.sax.SAXParseException: The string "--" is not permitted within comments.
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:174)
        at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:388)
        at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1411)
        at com.sun.org.apache.xerces.internal.impl.XMLScanner.scanComment(XMLScanner.java:774)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanComment(XMLDocumentFragmentScannerImpl.j
ava:1034)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragme
ntScannerImpl.java:2938)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:645)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.
java:508)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:807)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
        at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:107)

This happens if you attempt to use comments in your XML file (usually web.xml or server.xml) to draw lines. For example:

<!---------------------->
<!-- My comment -->
<!---------------------->

The problem is that -- is not allowed inside the comments. Try using something <!-- ====================== --> like instead.


To Resolve the following problem

org.xml.sax.SAXParseException: The content of element type "web-app" must match "(icon?,display-name?,description?,distributable?,context-param*,filter*,filter-mapping*,listener*,servlet*,servlet-mapping*,session-config?,mime-mapping*,welcome-file-list?,error-page*,taglib*,resource-env-ref*,resource-ref*,security-constraint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-local-ref*)".

The elements in the web.xml file must be in this order:

icon?,display-name?,description?,distributable?,context-param*,filter*,filter-mapping*,listener*,servlet*,servlet-mapping*,session-config?,mime-mapping*,welcome-file-list?,error-page*,taglib*,resource-env-ref*,resource-ref*,security-constraint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-local-ref*

--Rajendra P S, 18-Dec-2006


Hi Rajendra,

Some elements must be in the correct order, but most of them can be in any order at all. Normally the error indicates a an error in the structure of the XML only. If you have an example where this error appears on correctly structured XML, please send it to me and I'll analyse the ordering to provide the exact rules. In all my current tests, I can only see that servlets must be defined before servlet-mappings, and filters must be defined before filter-mappings.

Are you using Tomcat or a different container? Which version?

--NealeRudd, 20-Dec-2006


Hi i am getting the similar error...i dont know how to resolve it...

i am using websphere...while deploying the war file i am getting the error....Please help us to resolve this error..

[1/29/07 19:13:15:946 IST] 000000ed SystemErr     R Stack trace of nested exception:
[1/29/07 19:13:15:946 IST] 000000ed SystemErr     R org.eclipse.jst.j2ee.commonarchivecore.internal.exception.ResourceLoadException: IWAE0007E Could not load resource "WEB-INF/web.xml" in archive "Espace.war"
Stack trace of nested exception:
Wrapped exception
org.xml.sax.SAXParseException: The content of element type "web-app" must match "(icon?,display-name?,description?,distributable?,context-param*,filter*,filter-mapping*,listener*,servlet*,servlet-mapping*,session-config?,mime-mapping*,welcome-file-list?,error-page*,taglib*,resource-env-ref*,resource-ref*,security-constraint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-local-ref*)".
	at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown 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 Source)
	at org.apache.xerces.impl.dtd.XMLDTDValidator.endElement(Unknown Source)
	at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
	at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
	at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
	at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
	at org.eclipse.wst.common.internal.emf.utilities.DOMUtilities.loadDocument(DOMUtilities.java:546)
	at org.eclipse.wst.common.internal.emf.resource.EMF2DOMRenderer.loadDocument(EMF2DOMRenderer.java:72)
	at org.eclipse.wst.common.internal.emf.resource.EMF2DOMRenderer.doLoad(EMF2DOMRenderer.java:60)
	at org.eclipse.wst.common.internal.emf.resource.TranslatorResourceImpl.basicDoLoad(TranslatorResourceImpl.java:141)
	at org.eclipse.wst.common.internal.emf.resource.CompatibilityXMIResourceImpl.doLoad(CompatibilityXMIResourceImpl.java:173)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:977)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:832)
	at org.eclipse.wst.common.internal.emf.resource.TranslatorResourceImpl.load(TranslatorResourceImpl.java:384)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:249)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:264)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:349)
	at org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.LoadStrategyImpl.getMofResource(LoadStrategyImpl.java:342)
	at org.eclipse.jst.j2ee.commonarchivecore.internal.impl.ArchiveImpl.getMofResource(ArchiveImpl.java:869)
	at org.eclipse.jst.j2ee.commonarchivecore.internal.impl.ModuleFileImpl.getDeploymentDescriptorResource(ModuleFileImpl.java:255)
	at org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.XmlBasedImportStrategyImpl.primLoadDeploymentDescriptor(XmlBasedImportStrategyImpl.java:39)
	at org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.War22ImportStrategyImpl.loadDeploymentDescriptor(War22ImportStrategyImpl.java:87)
	at org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.War22ImportStrategyImpl.importMetaData(War22ImportStrategyImpl.java:81)
	at org.eclipse.jst.j2ee.commonarchivecore.internal.impl.WARFileImpl.getDeploymentDescriptor(WARFileImpl.java:150)
	at org.eclipse.jst.j2ee.commonarchivecore.internal.impl.WARFileImpl.getStandardDeploymentDescriptor(WARFileImpl.java:318)
	at org.eclipse.jst.j2ee.commonarchivecore.internal.impl.EARFileImpl.getDeploymentDescriptor(EARFileImpl.java:335)
	at org.eclipse.jst.j2ee.commonarchivecore.internal.impl.EARFileImpl.getDeploymentDescriptor(EARFileImpl.java:344)
	at org.eclipse.jst.j2ee.commonarchivecore.internal.impl.EARFileImpl.rollUpRoles(EARFileImpl.java:828)
	at org.eclipse.jst.j2ee.commonarchivecore.internal.impl.EARFileImpl.rollUpRoles(EARFileImpl.java:817)
	at com.ibm.websphere.management.application.client.ArchiveDeploymentInfo.<init>(ArchiveDeploymentInfo.java:155)
	at com.ibm.ws.management.application.client.AppInstallHelper.getAppDeploymentInfo(AppInstallHelper.java:188)
	...

--AnonymousCoward, 30-Jan-2007


Hi,

Can you send the contents of your web.xml file as well?

If it contains any private information (such as database passwords), please change that information before sending it.

Regards, Neale

--NealeRudd, 30-Jan-2007

navigation
metawerx specific
search
Share
tools
help

referring pages

Share