users@jaxb.java.net

Re: How to specify base type for a complexType

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Wed, 10 Dec 2008 11:20:31 -0800

Unfortunately using an exception as the base class for binding isn't
supported, according to the current rule of binding. This is because at
runtime the JAXB implementation will try to bind Exception to its own
complex type, which fails because it's not bindable.

I forgot the exact details but this was discussed between JAXB and
JAX-WS, because JAX-WS often need to bind exceptions.

It's probably worthwhile to file this as an issue, then record the
details, as this is obviously an useful feature --- we need a collective
memory of why this wasn't feasible.


Farrukh Najmi wrote:
> I have a compledxType hierarchy in my xsd that I would like to map to an
> Exception type hierachy in the generated bindings.
>
> Here is a sample of the xsd type hierarchy:
>
> <complexType name="RegistryExceptionType">
> </complexType>
>
> <complexType name="AuthenticationExceptionType">
> <complexContent>
> <extension base="tns:RegistryExceptionType">
> <sequence/>
> </extension>
> </complexContent>
> </complexType>
>
>
> I tried specifying the following customization:
>
> <jaxb:bindings node="xs:complexType[@name='RegistryExceptionType']">
> <jaxb:property>
> <jaxb:baseType name="java.lang.Exception"/>
> </jaxb:property>
> </jaxb:bindings>
>
> However, the generated class for RegistryExceptionType still did not
> extend java.lang.Exception as expected.
>
> What am I doing wrong?
>
> Thanks.
>
> --
> Farrukh
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>


-- 
Kohsuke Kawaguchi
Sun Microsystems                   http://weblogs.java.net/blog/kohsuke/