|
Re: Location of jaxb.index for JAXB [message #911909 is a reply to message #911626] |
Wed, 12 September 2012 15:08 |
|
Hi John,
The context path used to create a JAXBContext must be a valid package name. Your JAXB (JSR-222) implementation will look for a jaxb.index file there. The file itself is a carriage return separated list of classes that belong to that package.
-Blaise
|
|
|
|
Re: Location of jaxb.index for JAXB [message #912442 is a reply to message #911626] |
Thu, 13 September 2012 15:40 |
|
Hi John,
I'm happy to hear that you have found my blog, and answers on Stack Overflow helpful.
Standard JAXB Approach
The jaxb.index file needs to be in the same package as the classes it references. If you have classes in different packages then you could have a jaxb.index file per package.
What You Could Do
If the standard JAXB approach doesn't meet your requirements you could introduce your own config file, and then perform your own processing to convert the contents of that file to a Class[]. Then you could bootstrap a JAXBContext from that Class[].
-Blaise
[Updated on: Thu, 13 September 2012 17:36] Report message to a moderator
|
|
|
Re: Location of jaxb.index for JAXB [message #917012 is a reply to message #912442] |
Wed, 19 September 2012 18:30 |
John Raspet Messages: 3 Registered: September 2012 |
Junior Member |
|
|
Blaise Doughan wrote on Thu, 13 September 2012 11:40
If the standard JAXB approach doesn't meet your requirements you could introduce your own config file, and then perform your own processing to convert the contents of that file to a Class[]. Then you could bootstrap a JAXBContext from that Class[].
-Blaise
Blaise,
I'm attempting to pursue the solution quoted above as it seems like a good alternative. One hurdle I'm facing is using
javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory
I used to have this in my jaxb.properties file, but since I am no longer using a context path, I attempted to specify this property by using:
HashMap<String, Object> properties = new HashMap<String, Object>();
properties.put("javax.xml.bind.context.factory", "org.eclipse.persistence.jaxb.JAXBContextFactory");
Class<?>[] classes;
// ... load classes ...
JAXBContext jaxbContext = JAXBContext.newInstance(classes, properties);
and the result is:
javax.xml.bind.JAXBException: property "javax.xml.bind.context.factory" is not supported
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:114)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:202)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:363)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)
Any insight on how to continue using org.eclipse.persistence.jaxb.JAXBContextFactory when loading the classes from a file?
EDIT:
Scratch that, found another of your answers on SO that might work. I can't seem to link it since I have fewer than 25 messages, but for anyone else that might stumble on this issue, a quick google search for 6963996/can-i-replace-jaxb-properties-with-code should find the thread.
[Updated on: Thu, 20 September 2012 16:34] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.04117 seconds