2

Everything was working fine with my maven enabled project.

But when I rebuilt it today tests started to fail withe error

the property or field count on the class org.musicbrainz.mmd2.DiscList 
is required to be included in the propOrder element of the XmlType annotation

no code had changed so I assume something has changed in the eclipselink MOXy 2.5 snaphot jar.

I could resolve it by removing the offending mapping from oxml.xml

<java-type name="DiscList">
    <java-attributes>
        <xml-element java-attribute="count" name="disc-count"/>
    </java-attributes>
</java-type>

but then my resultant json is incorrect (because I need to rename count to disc-count).

I can fix it my modifying my DiscList.java class and adding to propOrder as suggested by the exception

i.e

from

@XmlType(name = "", propOrder = {
    "disc"    
})

to

@XmlType(name = "", propOrder = {
    "disc","count"
})

but that is a pain because these classes are generated automatically from a schema, I don't want to have to manually edit them every time the schema changes.

So the question really is what has changed in MOXy, and has this change introduced a bug ?

Paul Taylor
  • 13,411
  • 42
  • 184
  • 351

1 Answers1

0

We made this change to EclipseLink MOXy in versions 2.4.2 and 2.5.0 (both streams are currently in development). This change was made to mirror the corresponding behaviour in the JAXB reference implementation.

Related Bug

Recommended Fix

If you add a new mapping in the external mapping file (which is a bit rare since you would have had to explicitly remove the mapping via annotations - http://blog.bdoughan.com/2012/04/jaxb-and-unmapped-properties.html). Then you will need to override the propOrder in the external mapping file as well.

<java-type name="DiscList">
    <xml-type prop-order="disc count"/>
    <java-attributes>
        <xml-element java-attribute="count" name="disc-count"/>
    </java-attributes>
</java-type>

Send Us Your Feedback

We like to get feedback on changes we make, especially on streams that are still in development. This best mechanisms for this are:

For More Information


UPDATE

Thanks for the answer although I'm not convinced requiring me to add element to prop order just because I want to rename it is an improvement. I don't know why count is not already in the proplist I haven't taken it out it just wasn't added when the classes were autocreated with JAXB.

If your Java class was generated from an XML schema and count corresponds to an XML element then it should have been in the prop order. MOXy uses the same XJC code as the reference implementation and the JAXB RI also throws an exception if the propOrder is incomplete so I'm not sure what scenario would have excluded it. Would you mind posting the generated class? I would like to see if there is an actual bug here.

Also it would be useful if the eclipselink maven repository was browsable, the download.eclipse.org/rt/eclipselink/maven.repo page doesn't given any indication of changes made to the snapshot.

We're working on improving our Maven setup. I would recommend entering this as an enhancement request against the build component:

bdoughan
  • 147,609
  • 23
  • 300
  • 400
  • Thanks for the answer although I'm not convinced requiring me to add element to prop order just because I want to rename it is an improvement. I don't know why count is not already in the proplist I haven't taken it out it just wasn't added when the classes were autocreated with JAXB. Also it would be useful if the eclipselink maven repository was browsable, the http://download.eclipse.org/rt/eclipselink/maven.repo page doesn't given any indication of changes made to the snapshot. – Paul Taylor Nov 03 '12 at 21:51
  • I'm using JAXB 2.2.5 rather than MOXy for class generation, the full source code for schema generation is available from http://svn.musicbrainz.org/mmd-schema/trunk/brainz-mmd2-jaxb/ (note the last checkin of DiscList contains a manually modified propOrder, my fix before I saw yours) – Paul Taylor Nov 05 '12 at 10:43