Java XML Bind initialization exception

2
I'm having an error initializing xml bind. JAXBContext.newInstance(GetDocumentMTOMResponse.class.getPackage().getName(), GetDocumentMTOMResponse.class.getClassLoader()); When I call this code I get the following exception: Caused by: java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory not found by project [92] at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1532) at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75) at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1955) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) at javax.xml.bind.ContextFinder.safeLoadClass(ContextFinder.java:573) at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:145) at javax.xml.bind.ContextFinder.find(ContextFinder.java:361) at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:446) at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:409) at imageaccess.actions.GetDocumentRequest.init(GetDocumentRequest.java:179) The problem is it can't find the internal bind implementation. I noticed Mendix uses an implementation of the xml bind in their bundles. I tried copying the com.sun.xml.bind.jar file from bundles to userlib (I have also tried other implementations in userlib). If I do this, xml bind will load, but I get the following exception: java.lang.LinkageError: loader constraint violation: when resolving field "DATETIME" the class loader (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoaderJava5) of the referring class, javax/xml/datatype/DatatypeConstants, and the class loader (instance of <bootloader>) for the field''s resolved type, pe/DatatypeConstants, have different Class objects for that type at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl.<clinit>(RuntimeBuiltinLeafInfoImpl.java:267) at com.sun.xml.bind.v2.model.impl.RuntimeTypeInfoSetImpl.<init>(RuntimeTypeInfoSetImpl.java:65) at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.createTypeInfoSet(RuntimeModelBuilder.java:133) at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.createTypeInfoSet(RuntimeModelBuilder.java:85) at com.sun.xml.bind.v2.model.impl.ModelBuilder.<init>(ModelBuilder.java:156) at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.<init>(RuntimeModelBuilder.java:93) at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:455) at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:303) at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:142) at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1174) at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:162) at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:286) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:186) at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:146) at javax.xml.bind.ContextFinder.find(ContextFinder.java:348) at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:446) at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:409) at imageaccess.actions.GetDocumentRequest.init(GetDocumentRequest.java:179) The referenced class in this example is one in the userlib folder. However, it doesn't seem to matter what package, class or class loader I specify. I still get the same errors.
asked
1 answers
0

I understand you're doing this to work around a bug in MTOM? We plan to release an MTOM fix (wrong way to attach or include the attachment) in 5.21.x and 6.4.1 in about 2 weeks.

answered