Announcement Announcement Module
Collapse
No announcement yet.
Problem with Spring JAXB Version? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with Spring JAXB Version?

    Hi. I'm not sure yet if Spring is using an older? newer? version of JAXB, or there is some other JAXB config setting I'm missing. Anyway, the symptom is this:

    Using the airline project as a template, if I try to generate the JAXB source code for simpleTypes with enumerations, such as this:

    <code>
    <?xml version="1.0" encoding="UTF-8"?>
    <xsd:schema targetNamespace="http://www.uptodate.com"
    xmlns:tns="http://www.uptodate.com"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">

    <xsd:simpleType name="YorNTyp">
    <xsd:restriction base="xsd:string">
    <xsd:enumeration value="Y" />
    <xsd:enumeration value="N" />
    </xsd:restriction>
    </xsd:simpleType>
    </xsd:schema>
    </code>

    ...using Spring WS (recent download), JAXB doesn't generate the classes for the simpleTypes, and later, when I deploy the war, I get this error in the tomcat log:

    simpleType org.xml.sax.SAXParseException: src-resolve: Cannot resolve the name ... to a(n) 'type definition' component

    ...since it can't find the class associated with the simpleType.

    However, if I create a test project in Eclipse, and use the JAXB from Sun's JWSDP2.0, it generates a YorNTyp.java, as I would expect.

    I notice that the airline.xsd contains a simpleType with enumeration, but that it is not prefixed, i.e. is using a default namespace, which I am not.

    This got me curious as to which version of JAXB Spring is using for the Web Services, but more importantly, how can I fix my problem without having to change my xml schema a lot?

    Ben

  • #2
    In case someone else encounters this, changing the restriction base to "NCName" works around the problem. Ex:

    <simpleType name="YorNTyp">
    <restriction base="NCName">
    <enumeration value="Y" />
    <enumeration value="N" />
    </restriction>
    </simpleType>

    Not sure why yet, since base="NCName" is ultimately derived from base="string", according to my Xml Schema book.

    Ben

    Comment


    • #3
      We actually use JAXB 2.0.1 from https://jaxb.dev.java.net/

      Comment

      Working...
      X