jaxb
  1. jaxb
  2. JAXB-963

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

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Blocker Blocker
    • Resolution: Unresolved
    • Affects Version/s: 2.2.4u2
    • Fix Version/s: None
    • Component/s: xjc
    • Labels:
      None
    • Environment:

      Ubuntu 12.04.2, JDK 1.7.0_21

      Description

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

      {4}

      "/>
      </restriction>
      </simpleType>
      </schema>

      ---------- FILE B.xsd
      <schema targetNamespace="foo://b"
      xmlns="http://www.w3.org/2001/XMLSchema">
      <import namespace="foo://a" schemaLocation="boo://a.xsd"/>
      </schema>

      ---------- 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"/>
      </schema>

      ---------- FILE catalog.xml
      <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
      <system systemId="boo://a.xsd" uri="A.xsd"/>
      </catalog>

      ---------- FILE binding.xjb
      <bindings xmlns="http://java.sun.com/xml/ns/jaxb" version="2.1"/>

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

        Activity

        Hide
        markzimmngc added a comment -

        I am seeing this same issue with java version 1.7.0_45 and xjc 2.2.4-2 on RedHat.

        Show
        markzimmngc added a comment - I am seeing this same issue with java version 1.7.0_45 and xjc 2.2.4-2 on RedHat.
        Hide
        lexi added a comment -

        Related to or duplicate of https://java.net/jira/browse/JAXB-1045

        Show
        lexi added a comment - Related to or duplicate of https://java.net/jira/browse/JAXB-1045

          People

          • Assignee:
            Iaroslav Savytskyi
            Reporter:
            m_perdikeas
          • Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated: