XML : Jaxb cycle (infinite loop) marshalling error - MOXy and Spring OXM

I get a JAXB marshalling error (cycle infinite loop) - posted at end of this question.

I know it's due to a 2 way object reference and I have used EclipseLink MOXy JAXB marshaller in a test case to resolve this specifying ID and IDREF and specified the JAXB provider using a jaxb.properties file containing

  javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory    

However the production code uses Spring OXM and I cannot see how to achieve a similar result using this.

I have added a jaxb.properties file but it isn't being used - I know this because I add an empty file as a test and it doesn't complain (like it did on the prototype test case).

How do I specify the JAXB marshaller to use?

Exception: javax.xml.bind.MarshalException - with linked exception: [Exception [EclipseLink-25037] (Eclipse Persistence Services -
2.6.1.v20150916-55dc7c3):
org.eclipse.persistence.exceptions.XMLMarshalException Exception Description: A cycle is detected in the object graph. This will cause an infinite loop:
at org.eclipse.persistence.jaxb.JAXBMarshaller.marshal (JAXBMarshaller.java:487)

No comments:

Post a Comment