Aadarsh Sharma
Aadarsh Sharma

Reputation: 1

SAXParseException: Document is invalid: no grammar found. struts.xml

I am developing a Struts+Hibernate web application. I confronted with the following error with struts.xml:

Unable to load configuration. - file:/F:/BidNext/build/web/WEB-INF/classes/struts.xml:9:8**

org.xml.sax.SAXParseException; systemId: file:/F:/BidNext/build/web/WEB-INF/classes/struts.xml; >lineNumber: 9; columnNumber: 8; Document is invalid: no grammar found.

Here is my struts.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
    <package name="auction" extends="struts-default">
        <action name="signupaction" class="struts.action.SignUpAction">
            <result name="SUCCESS">/Home.jsp</result>
        </action>
    </package>
</struts>

Upvotes: 0

Views: 1021

Answers (1)

Roman C
Roman C

Reputation: 1

The error is when the application starts. The configuration file struts.xml which should be on classpath had parsed by the SAX parser to validate against document DTD supplied with the document. It has thrown an exception while parsing the document. It means that the document is invalid because it has wrong structure.

The line number and column number indicate where the invalid structure had started.

You can try to replace wrong configuration file and make sure only one configuration file with the same name exists per project.

You should keep this file along source file for making modifications. When you package the project the file should copy to the WEB-INF/classes in the war archive. Make sure the file is the same as on the source folder.

Make clean before the build to remove files used by the previous build.

Upvotes: 0

Related Questions