JDK-6402288 : Impossible to create javax.xml.validation.Schema instance from "web-app_2_4.xsd"
  • Type: Bug
  • Component: xml
  • Sub-Component: javax.xml.validation
  • Affected Version: 5.0
  • Priority: P2
  • Status: Closed
  • Resolution: Not an Issue
  • OS: generic
  • CPU: generic
  • Submitted: 2006-03-22
  • Updated: 2012-04-25
  • Resolved: 2006-07-12
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6Resolved
Description
When I try to create a javax.xml.validation.Schema instance off of the Servlet 2.4 deployment descriptor schema ("web-app_2_4.xsd"), I get the exception below.

To reproduce, compile the attached SchemaTester.java, unzip the attached schemas.jar.zip, and invoke this command:

  % java -classpath schemas.jar:. SchemaTester

I'm using jdk1.5.0_06.

Here's the exception I'm getting:

Exception in thread "main" org.xml.sax.SAXParseException: sch-props-correct.2: A schema cannot contain two global components with the same name; this schema contains two occurrences of 'http://java.sun.com/xml/ns/j2ee,descriptionGroup'.
        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.xs.traversers.XSDHandler.reportSchemaError(XSDHandler.java:2241)
        at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.checkForDuplicateNames(XSDHandler.java:1918)
        at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.buildGlobalNameRegistries(XSDHandler.java:983)
        at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.parseSchema(XSDHandler.java:478)
        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 SchemaTester.main(SchemaTester.java:19)

Comments
EVALUATION I've verified that the suggested fix does the trick. Thanks! I've modified the suggested fix to pass the "systemId" param to LSInput.setSystemId() instead of the result of MyLSResourceResolver.class.getResource (resourcePath).toString()
12-07-2006

EVALUATION On 07/11/06, Santiago Pericas-Geertsen <###@###.###> wrote: I had a chance to look at it. The double inclusion is actually a result of including the schema whose systemId is, "http://www.ibm.com/webservices/xsd/j2ee_web_services_client_1_1.xsd" Fortunately, there's a very simple solution. The problem is that the LSResourceResolver provided by the application returns an LSInput which does not include a systemId, i.e. without calling setSystemId (). Thus it is impossible for Xerces to detect a loop since it is basically just getting an InputStream which it doesn't know where it came from. Constructing the LSInput in the following way, in resolveResource (), solves the problem: MyLSInput ls = new MyLSInput(); ls.setByteStream(is); ls.setSystemId(MyLSResourceResolver.class.getResource (resourcePath).toString()); To summarize, Xerces does check for loops, but it needs the right information to do it.
12-07-2006

EVALUATION CR contains a test case & is being accepted for evaluation. note that any fixes may need to go into both Mustang JAXP 1.3.x repositories.
18-04-2006