Thursday, February 9, 2012

The prefix "jaxb" for element "jaxb:globalBindings" is not bound.

I'm using xjc to compile XML Schema into JAXB objects and the
compiling is fine unless I try to define jaxb bindings. For instance,
if I try adding this code in the schema:

<xs:annotation>
<xs:appinfo>
<jaxb:globalBindings generateIsSetMethod="true">
bindingStyle="modelGroupBinding"
choiceContentProperty="true" >

<xjc:serializable uid="12343"/>
<jaxb:javaType name="short"
xmlType="xs:long"
printMethod="javax.xml.bind.DatatypeConverter.printShort"
parseMethod="javax.xml.bind.DatatypeConverter.parseShort"/>
</jaxb:globalBindings>
</xs:appinfo>
</xs:annotation>

xjc complains with:
[ERROR] The prefix "jaxb" for element "jaxb:globalBindings" is not
bound.

SOLUTION
========

Missing namespace declaration. There should be something like this:
xmlns:jaxb="URI"
Just look for the other namespace definitions (i.e. xmlns:s) and
add the above attribute to the end.

Source : http://www.velocityreviews.com/forums/t137983-problem-in-xjc-with-recognizing-jaxb-prefix.html

No comments:

Post a Comment