| Summary | Annotation @XmlRootElement is not present on generate JAXB class |
|---|---|
| Article Number | 17494 |
| Environment | All Supported Operating Systems Artix 5.x Artix JAX-WS Runtime |
| Question/Problem Description | Annotation @XmlRootElement is not present on generate JAXB class javax.xml.bind.MarshalException because it is missing an @XmlRootElement annotation |
| Clarifying Information | |
| Error Message | |
| Defect/Enhancement Number | |
| Cause | When Artix 5.5 JAX-WS generates a Java class for an element with an in-line type definition, the class is decorated with the @XmlRootElement annotation. The schema definition in example 1 will generate a myElement class that contains the @XmlRootElement annotation. example 1:
However example 2 (below) will NOT generate a myElement class that contains the @XmlRootElement annotation. Example 2:
|
| Resolution |
Modifying the schema definition to an in-line type definition will generate an element class that contains @XmlRootElement annotation. However it is possible to unmarshal the element defined in example 2, from an XML string to JAXB object using the following code: import javax.xml.bind.JAXBContext;import javax.xml.bind.JAXBElement;
import javax.xml.bind.Unmarshaller; import javax.xml.transform.stream.StreamSource; ... InputStream is = ... // set to valid XML string for element myElement JAXBContext jaxbContext = JAXBContext.newInstance(MyComplexType.class); Unmarshaller u = jaxbContext.createUnmarshaller();
JAXBElement<MyComplexType> root = u.unmarshal(new StreamSource(is),MyComplexType.class); For more information on generated JAXB classes and annotations see Artix documentation "Developing Artix Applications with JAX-WS", "Using XML Elements" .
|
| Workaround | |
| Notes | |
| Attachment |
| Created date: | 06 September 2011 |
|---|---|
| Last Modified: | 13 February 2013 |
| Last Published: | 23 June 2012 |
| First Published date: | 09 September 2011 |
#Orbix
#KnowledgeDocs




