How do you get the MOXy oxml file for recognizing static classes

Using MOXy, I can smooth parts of my object model in my json file

ie

<java-type name="Medium">
  <java-attributes>
    <xml-element java-attribute="trackList" xml-path="."/>
  </java-attributes>
</java-type>

but when I want to reset a class that is a descendant of a static class as follows

<java-type name="Medium.TrackList">
  <java-attributes>
    <xml-element java-attribute="artistList" xml-path="."/>
  </java-attributes>
</java-type>

he complains

Exception Description: Could not load class [Medium.TrackList] declared in the external metadata file.  Please ensure that the class name is correct, and that the correct ClassLoader has been set.
    at org.eclipse.persistence.exceptions.JAXBException.couldNotLoadClassFromMetadata(JAXBException.java:376)
    at org.eclipse.persistence.jaxb.JAXBContext$TypeMappingInfoInput.getXmlBindingsClasses(JAXBContext.java:979)
    at org.eclipse.persistence.jaxb.JAXBContext$TypeMappingInfoInput.createContextState(JAXBContext.java:879)
    at org.eclipse.persistence.jaxb.JAXBContext.<init>(JAXBContext.java:157)

How to resolve this?

+4
source share
1 answer

EclipseLink really expects the $ separator when specifying inner classes in OXM. I reproduced your problem and fixed it by modifying it in your oxm file.

<java-type name="Medium$TrackList">
  <java-attributes>
    <xml-element java-attribute="artistList" xml-path="."/>
  </java-attributes>
</java-type>

Hope this helps,

Rick

+3
source

All Articles