How to create JAXBContext in EclipseLink?

JAXBContext.newInstance()gets Mapwith properties as a parameter.

What properties and how should I specify in order to make an instance JAXBContextinformed of several files with xml-mappings?

The example shows how to specify only one file in a way that is unacceptable for real systems (i.e. c new File(address)). Instead, I need to use classLoader.getResource()that which returns an object URL.

Thank!

UPD:

When I try to instantiate a JAXBContext, I get this release:

javax.xml.bind.JAXBException: property "eclipselink-oxm-xml" is not supported
    at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:118)
    ...

Obviously, the file was jaxb.propertiesnot found at startup. Where should I put this? (I use the maven, and in fact I tried to put it in /target/jaxb.properties, /target/classes/jaxb.properties, /target/classes/META-INF/definitions/jaxb.properties- close to the xml-mapping file, and /target/classes/com/myproject/experiment/jaxb.properties- next to the class that is trying to create an instance of JAXBContext).

+3
source share
1 answer

The external clip file E clipseLink JAXB (MOXy) can be in any of the following formats (or in the list):

  • java.io.File
  • java.io.InputStream
  • java.io.Reader
  • java.net.URL
  • javax.xml.stream.XMLEventReader
  • javax.xml.stream.XMLStreamReader
  • javax.xml.transform.Source
  • org.w3c.dom.Node
  • org.xml.sax.InputSource

MOXy JAXB, jaxb.properties :

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

All Articles