Reputation: 66156
JAXBContext.newInstance()
method receives Map
with properties as a parameter.
Which properties and how should I specify to make JAXBContext
instance informed about several files with xml-mappings?
Example shows how to specify only one file in a way which is not acceptable in real systems (i.e. with new File(address)
). Instead of this I need to use classLoader.getResource()
which returns URL
object.
Thanks!
UPD:
When I try to instantiate JAXBContext I get this exeption:
javax.xml.bind.JAXBException: property "eclipselink-oxm-xml" is not supported
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:118)
...
It's obvious that jaxb.properties
file is not found at start up. Where should I put it? (I'm using maven, and actually I've tried to put it to /target/jaxb.properties
, /target/classes/jaxb.properties
, /target/classes/META-INF/definitions/jaxb.properties
- it's near xml-mapping file, and /target/classes/com/myproject/experiment/jaxb.properties
- it's near the class which tries to instantiate JAXBContext).
Upvotes: 3
Views: 2639
Reputation: 148977
The EclipseLink JAXB (MOXy) external bindings file can be in any of (or a List of) the following formats:
To use MOXy as your JAXB provider you also need to include a file named jaxb.properties with your model classes with the following entry:
javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory
Upvotes: 2