[
https://issues.apache.org/jira/browse/WINK-219?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Mike Rheinheimer updated WINK-219:
----------------------------------
Attachment: WINK-219.patch
I must be doing something wrong. :) If I read this jira and WINK-218
correctly, we expect JAXB to be able to handle an inherited JAXB type that has
no JAXB annotations. So I might have:
{code}
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"arg0",
"arg1"
})
@XmlRootElement(name = "addNumbers")
public static class AddNumbers { }
public static class AddInts extends AddNumbers { }
{code}
And expect to be able to do this:
{code}
AddInts addInts = new AddInts();
// JAXBContext can handle inherited types?
JAXBContext context = JAXBContext.newInstance(AddInts.class);
Marshaller marshaller = context.createMarshaller();
Writer writer = new StringWriter();
marshaller.marshal(addInts, writer);
{code}
This didn't work out so good for me. I got exception:
{code}
...
Caused by: com.sun.istack.SAXException2: unable to marshal type
"org.apache.wink.server.internal.providers.entity.JAXBProviderInheritanceTest$AddInts"
as an element because it is missing an @XmlRootElement annotation
at
com.sun.xml.bind.v2.runtime.XMLSerializer.reportError(XMLSerializer.java:242)
at
com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeRoot(ClassBeanInfoImpl.java:303)
at
com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:488)
at
com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:317)
... 22 more
{code}
So, I put the @XmlRootElement annotation on my AddInts class, and it succeeds.
In fact, the only check the JAXBXmlProvider performs before allowing the
creation of the marshaller/unmarshaller instances is for the @XmlRootElement
annotation. Looks like JAXBXmlProvider is doing the necessary and appropriate
check. So I think we're all done here. Maybe this got fixed between opening
the jira and now?
Anyway, please review and confirm. See attached test patch.
> JAXBXmlProvider should be able to handle inherited types, since JAXB is able
> to handle them
> -------------------------------------------------------------------------------------------
>
> Key: WINK-219
> URL: https://issues.apache.org/jira/browse/WINK-219
> Project: Wink
> Issue Type: Bug
> Components: Common
> Affects Versions: 1.0
> Reporter: Kaloyan Kolev
> Assignee: Mike Rheinheimer
> Priority: Minor
> Attachments: WINK-219.patch
>
>
> Here is the issue which led to opening this one:
> https://issues.apache.org/jira/browse/WINK-218
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.