This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
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"); sf.newSchema(url);
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 'code-source:/C:/ADE/rchalava_vw3/oracle%20spaces/mds/lib/mdsrt.jar!/oracle/mds/xsd/mdsConfig.xsd', 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)
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.
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.