PDA

View Full Version : Problem with Spring JAXB Version?



benethridge
Jun 29th, 2006, 03:32 PM
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

benethridge
Jun 29th, 2006, 03:51 PM
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

Arjen Poutsma
Jun 30th, 2006, 01:53 AM
We actually use JAXB 2.0.1 from https://jaxb.dev.java.net/