Marshalling object fails with JAXB and CXF, throws nullpointerexception
-----------------------------------------------------------------------
Key: CXF-3161
URL: https://issues.apache.org/jira/browse/CXF-3161
Project: CXF
Issue Type: Bug
Components: JAXB Databinding
Environment: Windows XP; Eclipse 3.5.2; jaxb-api-2.2.1;
jaxb-impl-2.2.1;
Reporter: Paul Jutten
The following methods are included in the generated objectfactory:
{code:title=ObjectFactory.java|borderStyle=solid}
@XmlElementDecl(namespace = "http://test.nl/voertuigen", name = "kleur")
public JAXBElement<KleurType> createKleur(KleurType value)
{
return new JAXBElement<KleurType>(_Kleur_QNAME, KleurType.class, null,
value);
}
@XmlElementDecl(namespace = "http://test.nl/voertuigen", name = "kleur", scope
= BusType.class)
public JAXBElement<MetallicKleurType> createBusTypeKleur(MetallicKleurType
value)
{
return new JAXBElement<MetallicKleurType>(_Kleur_QNAME,
MetallicKleurType.class, BusType.class, value);
}
{code}
Both methods have the same namespace and name, the createBusTypeKleur method
also has a scope (in @XmlElementDecl). KleurType and MetallicKleurType are
enums.
When I marshall the BusType object with CXF, a nullpinterexception is thrown.
The BusType class looks like this:
{code:title=BusType.java|borderStyle=solid}
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "busType", propOrder = {"kleur"})
public class BusType
{
XmlElementRef(name = "kleur", namespace = "http://test.nl/voertuigen",
type = JAXBElement.class)
protected JAXBElement<MetallicKleurType> kleur;
public JAXBElement<MetallicKleurType> getKleur()
{
return kleur;
}
public void setKleur(JAXBElement<MetallicKleurType> value)
{
this.kleur = (value);
}
}
{code}
When the method createKleur in the ObjectFactory class has a scope too, or the
names in the @XmlAccessorType are different, no exceptions will be thrown.
I have attached the source code (as small Eclipse project).
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.