15

I'm getting the errors in my Struts application, on my development machine, saying apparently my config files have errors (which I already checked and seem ok):

org.apache.commons.digester.Digester error
    SEVERE: Parse Error at line 3 column 15: Document is invalid: no grammar found.
    org.xml.sax.SAXParseException: Document is invalid: no grammar found.


org.apache.commons.digester.Digester error
    SEVERE: Parse Error at line 3 column 15: Document root element "struts-config", must match DOCTYPE root "null".
    org.xml.sax.SAXParseException: Document root element "struts-config", must match DOCTYPE root "null".

Apparently, on development machine the application manages to run. However, on the deploy server I get the following errors, which I don't know if might be related:

    org.apache.struts.action.ActionServlet handleConfigException 
SEVERE: Parsing error processing resource path /WEB-INF/struts-config.xml java.net.ConnectException: Connection refused at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351) at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)

My struts-config.xml file: http://pastebin.com/i0XanZZt My web.xml file: http://pastebin.com/jMPAdSUm

What can possibly be wrong here? Some lib missing? Incorrect lib versions (using latest Struts 1 release)?

Thanks in advance!

Rui
  • 5,900
  • 10
  • 38
  • 56
  • Can you remove the doctype and test? – bluesman Apr 26 '12 at 19:39
  • Hey, I've tested and I get the same errors :S – Rui Apr 26 '12 at 20:56
  • FWIW, I recently introduced errors similar to the first 2 into the console in an app I'm working on. However, everything seems to work fine, so I would regard this as a warning, not an error. (Still, it's good to fix whatever is causing the warning. I'm still googling this issue.) The 3rd error you listed is unrelated, I'm pretty sure. – jyoungdev Dec 18 '12 at 15:13
  • Hey @Rui have you found any solution to this problem ? I'm struggling with right now .. – mounaim Oct 30 '14 at 11:23

4 Answers4

12

Just went through the struggles of something very similar. Was also receiving the org.xml.sax.SAXParseException: Document is invalid: no grammar found. Original developer had setValidation(true) for the Digester and then was trying to validate using a schema. When validation is set to true it expects a DTD in the DOCTYPE declaration of the XML. So when one is not found the Exception occurs.

Solution: DO NOT set validation to true on the Digester when validating using a schema.

Below is good link that shows how to set up the Digester where it defines schema for the Digester to use. Of course if schema is defined in the xml then there is no need to define a schema for the Digester and validation will occur automatically.

http://alvinalexander.com/java/jwarehouse/commons-digester/src/test/java/org/apache/commons/digester/XMLSchemaTestCase.java.shtml

Hope this helps...

user2543287
  • 121
  • 1
  • 3
3

For those who doing JPOS, add these two lines in xml file

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE isopackager SYSTEM "genericpackager.dtd">
John Joe
  • 12,412
  • 16
  • 70
  • 135
2

Just check struts.xml, correct the following and run your program.

<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" "http://struts.apache.org/dtds/struts-2.3.dtd">
Amani Kilumanga
  • 324
  • 10
  • 23
Pradeep Yadava
  • 91
  • 1
  • 1
  • 6
1

Got this trying to do XSD validation using SAX:

Caused by: org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 30; Document is invalid: no grammar found.
    at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)

Fix seemed to be add this:

 saxParser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);

ref: https://docs.oracle.com/javase/tutorial/jaxp/sax/validation.html

rogerdpack
  • 62,887
  • 36
  • 269
  • 388