users@jaxb.java.net

Re: Making generated classes serializable

From: Ryan O'Connell <Ryan.Oconnell_at_Sun.COM>
Date: Fri, 12 Jun 2009 11:04:33 -0400

I upgraded from JAXB 2.0 to the latest 2.1.11 version and the original
binding file now seems to work. I also had to modify my xjc ant
invocation since it looks like the target attribute was changed to destdir.

Thanks to those who tried to help.
--ryano


Ryan O'Connell wrote:
> Hello,
>
> In the past I was able to compile DTDs using JAXB. I also specified a
> custom binding that made each implementation class Serializable. The
> version of JAXB I was using created interfaces for all XML content as
> well as impls of those interfaces
>
> The binding file contained the following content:
>
> <?xml version="1.0" ?>
> <xml-java-binding-schema xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc">
> <xjc:serializable uid="1" />
> </xml-java-binding-schema>
>
> And I invoked the JAXB compiler using the xjc task like so:
>
> <xjc schema="${ts.home}/lib/dtds/sun-application_5_0-0.dtd"
> binding="${ts.home}/src/${porting.package.dir}/jaxb-cust.xml"
> target="${ts.home}/src"
> package="${porting.package}.app">
> <arg value="-dtd"/>
> <depends dir="${ts.home}/lib/dtds"
> includes="sun-application_6_0-0.dtd"/>
> <produces dir="${ts.home}/src/${porting.package.dir}/app"
> includes="**/*"/>
> </xjc>
>
>
> At some point I upgraded to JAXB 2.x and I noticed interfaces were no
> longer generated just plain Java classes, and I also noticed my
> classes did not implement Serializable. I have tried many variations
> of binding file and I can't seem to make it work. This binding file
> seems like it should work:
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
> version="2.0">
> <jaxb:globalBindings>
> <jaxb:serializable/>
> </jaxb:globalBindings>
> </jaxb:bindings>
>
> but I keep getting the following error:
>
> [xjc] [ERROR] cvc-elt.1: Cannot find the declaration of element
> 'jaxb:globalBindings'.
> [xjc] line 3 of
> file:/Users/ryanoconnell/Documents/workspace/spider/src/com/sun/ts/lib/implementation/sun/javaee/runtime/jaxb-cust.xml
>
>
>
> Can anyone tell me where I fell off the beam?
>
> Thanks in advance.
> --ryano