jaxb-ri icon indicating copy to clipboard operation
jaxb-ri copied to clipboard

JAXB xjc crashes while parsing trivial 8-line XSD file when -binding is used together with -catalog

Open Tomas-Kraus opened this issue 11 years ago • 6 comments

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"> <pattern value="\d

{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 <system systemId="boo://a.xsd" uri="A.xsd"/>

---------- 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]

Tomas-Kraus avatar Jun 12 '13 09:06 Tomas-Kraus

  • Issue Imported From: https://github.com/javaee/jaxb-v2/issues/963
  • Original Issue Raised By:@glassfishrobot
  • Original Issue Assigned To: @glassfishrobot

Tomas-Kraus avatar Sep 21 '18 16:09 Tomas-Kraus

@glassfishrobot Commented Reported by m_perdikeas

Tomas-Kraus avatar Jun 12 '13 09:06 Tomas-Kraus

@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.

Tomas-Kraus avatar Dec 20 '13 17:12 Tomas-Kraus

@glassfishrobot Commented lexi said: Related to or duplicate of https://java.net/jira/browse/JAXB-1045

Tomas-Kraus avatar Oct 03 '14 20:10 Tomas-Kraus

@glassfishrobot Commented Was assigned to yaroska

Tomas-Kraus avatar Jun 12 '13 09:06 Tomas-Kraus

@glassfishrobot Commented This issue was imported from java.net JIRA JAXB-963

Tomas-Kraus avatar Apr 24 '17 12:04 Tomas-Kraus