java - PropertyException when setting Marshaller property with eclipselink.media-type value: application/json -
i'm attempting follow example located here javax.xml.bind.propertyexception. receive exception because of following line of code:
marshaller.setproperty("eclipselink.media-type", "application/json");
i have literally copy/pasted example listed above code see there. searching , google has not been helpful, , thought i'd bring geniuses @ help. appreciated, (de)serialization json , xml json.org, jackson, , jaxb has turned black , bottomless pit has consumed month of life.
my first impression wasn't specifying eclipselink runtime (as described here) didn't produce solution.
stacktrace:
exception in thread "main" javax.xml.bind.propertyexception: name: eclipselink.media-type value: application/json @ org.eclipse.persistence.jaxb.jaxbmarshaller.setproperty(jaxbmarshaller.java:528) @ com.dualoutput.dualoutput.main(dualoutput.java:20)
you need sure using eclipselink 2.4.0 or above. current version 2.5.0 can downloaded @ (or obtained maven central):
update
moxy offers following convenience classes access extension properties:
org.eclipse.persistence.jaxb.jaxbcontextproperties
org.eclipse.persistence.jaxb.marshllerproperties
org.eclipse.persistence.jaxb.unmarshallerproperties
this means following:
marshaller.setproperty(marshallerproperties.media_type, "application/json");
Comments
Post a Comment