wood burning stoves 2.0
The moose likes XML and Related Technologies and the fly likes SAXParseException: schema_reference.4: Failed to read schema document Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "SAXParseException: schema_reference.4: Failed to read schema document" Watch "SAXParseException: schema_reference.4: Failed to read schema document" New topic

SAXParseException: schema_reference.4: Failed to read schema document

rajesh chalavadi

Joined: Feb 13, 2008
Posts: 7
I am running into following SAXParseException when I am trying to create a Schema from a URL with the following code.

SchemaFactory sf = ShemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");

I have verified that schema document exists at the location of URL. Initially I thought this is because of space chars in the URL. But even after encoding the URL, I am running into the this exception.

Could any one please let me know the cause for this exception? Any help in this regard is highly appreciated.

Caused by: org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document
because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:172)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:382)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:316)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaError(XSDHandler.java:2245)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getSchema(XSDHandler.java:1590)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.parseSchema(XSDHandler.java:438)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadSchema(XMLSchemaLoader.java:556)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:523)
at com.sun.org.apache.xerces.internal.jaxp.validation.xs.SchemaFactoryImpl.newSchema(SchemaFactoryImpl.java:206)
at javax.xml.validation.SchemaFactory.newSchema(SchemaFactory.java:489)
at javax.xml.validation.SchemaFactory.newSchema(SchemaFactory.java:521)
Paul Clapham

Joined: Oct 14, 2005
Posts: 19458


That's a strange URL. I've never seen the "code-source" protocol before. I suppose you don't have anything supporting that protocol?
rajesh chalavadi

Joined: Feb 13, 2008
Posts: 7
'code-source' URL is specific to ORACLE Application server.

Please find more details in http://static.springframework.org/spring/docs/2.0.x/api/org/springframework/util/ResourceUtils.html

about various protocols of websphere, weblogic, Oracle App server etc.
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 12937
If this was my problem I would try to parse the schema document using SAX in order to use the better error reporting you can get out of an SAXParseException - namely the line number and column number triggering the fault (if the problem is actually in the document.)

If the problem is really in locating the document in the first place, some sort of IOException will probably occur.

The error message you are getting now is not much help.


Joined: Oct 15, 2008
Posts: 7
hi.. even i am getting the same kind of error...

i have implemented the code in similar manner as specified in the site Cinnamon Service

i am using with spring and haave deployed the service using cinnamon.

any help with this will be appreciated.
Pragya Patnaik

Joined: Dec 03, 2009
Posts: 7
Same with me even...
getting the same error. verified using external application, it is working fine but by using Schema factory getting error:Failed to read schema..

Any more suggestions for this??
Mansoor Shaikh

Joined: Jul 22, 2013
Posts: 1
Even I am facing the same issue. Was anyone able to resolve it, if yes, can you please post the solution. It is working in eclipse but not from command line.
I am using the below command line, I have ensured that all files and version in the maven POM files are correct and they exists.

java -cp jarfilename fullyqualityclassname

I agree. Here's the link: http://aspose.com/file-tools
subject: SAXParseException: schema_reference.4: Failed to read schema document