[ https://issues.apache.org/jira/browse/CXF-3161?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Daniel Kulp resolved CXF-3161. ------------------------------ Resolution: Not A Problem Fix Version/s: Invalid Assignee: Daniel Kulp The JAXBElement<MetallicKleurType> kleur that is set into the BusType object needs to have it's scope set so that the lookup within JAXB runtime can find the correct kleur element handler. Ideally, use the ObjectFactory.createBusTypeKleur method, but adding the BusType.class class to the constructor would work. In anycase, this isn't a CXF bug at all. At best, it could be logged with JAXB to have them produce a better error message or handle scoping better. > 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 > Assignee: Daniel Kulp > Fix For: Invalid > > Attachments: JaxBProject.zip > > > 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. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira