Community
Participate
Working Groups
Build Identifier: 2.2.0.v20110202-r8913 If i have following setup: - Bundle A containing XJC generated classes and a facade for the marshalling code - Bundle B has the un-/marshaller code - An UI thread calls the facade from Bundle A with an classloader which can load classes from every OSGi bundle The JAXBContext is created using the above mentioned classloader: JAXBContextFactory.createContext(contextPath, classLoader); While creating the context, the ObjectFactory.java from the generated classes in Bundle A is loaded and check if it is a JAXB ObjectFactory. The check fails because the check, if the class is annotated as object factory, is done with the wrong classloader (see line 153 and 379 ind JAXBContextFactory.java [trunk version]). Furthermore the check is done without a classloader. So the situation is somehting like this: the supplied object factory class in method isJAXB2ObjectFactory is loaded by my own classloader (and hence the annotations in it) while the annotation which is used to the check it is loaded with the UI threads classloader. Thus the method returns false and the ObjectFactory check is worthless. Reproducible: Always
Created attachment 194918 [details] Patch to solve the problem This patch passes the classloader to the isJAXB2ObjectFactory and loads the annotation with the specific classloader. The patch is for the trunk version of moxy. If a patch for the specific version 2.2.0.v20110202-r8913 is need i can supply it too.
Created attachment 195127 [details] Fix for the same issue with XmlSeeAlso
Proposed fix looks good. The same issue exists for the XmlSeeAlso annotation. That annotation class is also loaded using the same API without passing in the correct ClassLoader.
Attached patches checked into trunk stream in SVN
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink