users@jaxb.java.net

Re: IllegalAnnotationsException when _at_XmlValue and _at_XmlJavaTypeAdapter both present in xjc generated code.

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Tue, 19 Dec 2006 10:32:59 -0800

How does the definition of PropertyValue look like?


Scudieri, Chris (IT) wrote:
> Usage of baseType is not well documented so I may be outside of the
> intention of the Spec.
> However what XJC is generating is extremely close to what I am looking
> for. I am trying
> to get an XmlAdapter to marshal/unmarshall the value of the Property
> element and have run into the
> Following issue:
>
> Schema snippet:
>
> <xs:complexType name="Property" >
> <xs:annotation><xs:appinfo>
> <jaxb:property>
> <jaxb:baseType>
> <xjc:javaType name="com.test.PropertyValue"
> adapter="com.test.PropertyAdapter" />
> </jaxb:baseType>
> </jaxb:property>
> </xs:appinfo></xs:annotation>
>
> <xs:simpleContent>
> <xs:extension base="PropertyType">
> <xs:attribute name="type" type="PropertyTypes" />
> </xs:extension>
> </xs:simpleContent>
> </xs:complexType>
>
> Where:
> PropertyType is essentially anySimpleType
> PropertyTypes is a string enum
>
>
>
> Generated Property.java:
> public class Property {
>
> @XmlValue
> @XmlJavaTypeAdapter(PropertyAdapter.class)
> protected PropertyValue value;
> @XmlAttribute
> protected PropertyTypes type;
>
>
> However attempting to create a context throws an
> IllegalAnnotationsException:
>
> com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of
> IllegalAnnotationExceptions
> @XmlAttribute/_at_XmlValue need to reference a Java type that maps to text
> in XML.
> this problem is related to the following location:
> at protected com.test.PropertyValue
> com.test.generated.Property.value
> at com.test.generated.Property
> at public com.test.generated.Property
> com.test.generated.ObjectFactory.createProperty()
> at com.test.generated.ObjectFactory
>
> at
> com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check(Il
> legalAnnotationsException.java:66)
> at
> com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextIm
> pl.java:405)
> at
> com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:
> 253)
> at
> com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:84)
> at
> com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:66)
> at
> com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:132
> )
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
> a:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
> Impl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585)
> at
> javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:132)
> at javax.xml.bind.ContextFinder.find(ContextFinder.java:285)
> at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:372)
> at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:337)
> at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:244)



-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com