Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>When I run your example I get the same thing. The error message is correct <code>unexpected element (uri:"", local:"artist")</code> the element exists in the XML but you have not mapped to it. The expected elements you have mapped to are <code>&lt;{}id&gt;,&lt;{}released&gt;,&lt;{}name&gt;,&lt;{}availability&gt;</code> the element <code>&lt;{}artist&gt;</code> does not appear there because you have excluded it with <code>@XmlTransient</code>.</p> <pre><code>DefaultValidationEventHandler: [ERROR]: unexpected element (uri:"", local:"artist"). Expected elements are &lt;{}id&gt;,&lt;{}released&gt;,&lt;{}name&gt;,&lt;{}availability&gt; Location: line 6 of file:/Users/bdoughan/GIT/EclipseLink-Trunk3/Scratch/src/dao/spotify/test5.xml javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"artist"). Expected elements are &lt;{}id&gt;,&lt;{}released&gt;,&lt;{}name&gt;,&lt;{}availability&gt; at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:642) </code></pre> <p>Note about <code>DefaultValidationEventHandler</code>. This class represents the default validation event rules for JAXB 1.0 which are different from JAXB 2.0. The following is from the Javadoc (see: <a href="http://docs.oracle.com/javase/7/docs/api/javax/xml/bind/helpers/DefaultValidationEventHandler.html" rel="nofollow">http://docs.oracle.com/javase/7/docs/api/javax/xml/bind/helpers/DefaultValidationEventHandler.html</a>)</p> <blockquote> <p>JAXB 1.0 only default validation event handler. This is the default handler for all objects created from a JAXBContext that is managing schema-derived code generated by a JAXB 1.0 binding compiler.</p> <p>This handler causes the unmarshal and validate operations to fail on the first error or fatal error.</p> <p>This handler is not the default handler for JAXB mapped classes following JAXB 2.0 or later versions. Default validation event handling has changed and is specified in Unmarshaller and Marshaller.</p> </blockquote> <p>If you had not specified this as the <code>ValidationEventHandler</code> then your document would have unmarshalled correctly.</p> <hr> <h2>UPDATE</h2> <blockquote> <p>I'm afraid I don't understand; I thought that I had mapped artist when specifying: private LookupInnerArtist artist;? When changing the DefaultValidationEventHandler to ValidationEventCollector (correct?) everything works fine, even if I have specified artist as @XmlTransient. </p> </blockquote> <p>Since you have specified <code>@XmlAccessorType(XmlAccessType.FIELD)</code> all fields except those annotated with <code>@XmlTransient</code> will be considered mapped.</p> <blockquote> <p>I can still see artist when debugging, though it has a null value.</p> </blockquote> <p>Even though <code>artist</code> is annotated with <code>@XmlTransient</code> it still remains available on your class. Since it is now considered unmapped it will not be populated by the unmarshal operation.</p> <p><strong>For More Information</strong></p> <ul> <li><a href="http://blog.bdoughan.com/2012/04/jaxb-and-unmapped-properties.html" rel="nofollow">http://blog.bdoughan.com/2012/04/jaxb-and-unmapped-properties.html</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload