jaxb-ri
jaxb-ri copied to clipboard
JAXB xjc crashes while parsing trivial 8-line XSD file when -binding is used together with -catalog
Below is the absolute trivial, minimal example that demonstrates the problem.
Three schema files: A.xsd, B.xsd, C.xsd in the following import configuration:
- C.xsd imports A.xsd and B.xsd
- B.xsd imports A.xsd
So A.xsd is imported directly by C.xsd and again indirectly through B.xsd. The problem occurs when trying to run xjc (ver. 2.2.4) on C.xsd when both a catalog and a binding file is used (even an empty one).
---------- FILE A.xsd
<schema targetNamespace="foo://a"
xmlns="http://www.w3.org/2001/XMLSchema">
<simpleType name="year">
{4}
"/> </simpleType>
---------- FILE B.xsd <schema targetNamespace="foo://b" xmlns="http://www.w3.org/2001/XMLSchema"> <import namespace="foo://a" schemaLocation="boo://a.xsd"/>
---------- FILE C.xsd <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="foo://c"> <import namespace="foo://a" schemaLocation="A.xsd"/> <import namespace="foo://b" schemaLocation="B.xsd"/>
---------- FILE catalog.xml
---------- FILE binding.xjb
Given the above files, all placed in the same directory the below invocation succeeds:
xjc -d src -extension -catalog catalog.xml C.xsd
whereas the following invocation:
xjc -d src -extension -catalog catalog.xml C.xsd -b bindings.xjb
... fails with the bug-like message (pointing to some internal mess-up?):
parsing a schema... [ERROR] 'year' is already defined line 8 of file:/home/brutus/A.xsd
[ERROR] (related to above error) the first definition appears here line 3 of file:/home/brutus/A.xsd
Failed to parse a schema.
All components of the above minimal reproduction are necessary to trigger the bug. If no binding file is used xjc parses correctly and generates code. If no catalog file is used xjc parses correctly and generates code. If both binding file an catalog are used xjc fails to parse. This is a blocking issue at least in my particular case as the XSD files are given and cannot be modified and I have to use both a catalog and a binding file (to get around other issues).
Environment
Ubuntu 12.04.2, JDK 1.7.0_21
Affected Versions
[2.2.4u2]
- Issue Imported From: https://github.com/javaee/jaxb-v2/issues/963
- Original Issue Raised By:@glassfishrobot
- Original Issue Assigned To: @glassfishrobot
@glassfishrobot Commented Reported by m_perdikeas
@glassfishrobot Commented markzimmngc said: I am seeing this same issue with java version 1.7.0_45 and xjc 2.2.4-2 on RedHat.
@glassfishrobot Commented lexi said: Related to or duplicate of https://java.net/jira/browse/JAXB-1045
@glassfishrobot Commented Was assigned to yaroska
@glassfishrobot Commented This issue was imported from java.net JIRA JAXB-963