The same desktop application, when launched as an OSGi plug-in (JDK1.8), throws NoClassDefFoundError: javax/xml/bind/JAXBException for the above mentioned conversion.
Upon adding the below dependencies:
- Code: Select all
implementation group: 'org.docx4j', name: 'docx4j-JAXB-Internal', version: '8.2.8'
implementation group: 'org.docx4j', name: 'docx4j-JAXB-ReferenceImpl', version: '8.2.8'
implementation group: 'org.docx4j', name: 'docx4j-JAXB-MOXy', version: '8.2.8'
I get this error:
- java.lang.linkageerror: loader constraint violation: when resolving interface method "javax.xml.stream.XMLStreamReader.getNamespaceContext()Ljavax/xml/namespace/NamespaceContext;"
the class loader "" (instance of org.apache.felix.framework.BundleWiringImpl$BundleClassLoader@2dd2e270, child of sun.misc.Launcher$AppClassLoader@277050dc)
of the current class, org/eclipse/persistence/internal/oxm/record/namespaces/UnmarshalNamespaceContext,
and the class loader for the method's defining class, javax/xml/stream/XMLStreamReader,
have different Class objects for the type javax/xml/namespace/NamespaceContext used in the signature
at org.eclipse.persistence.internal.oxm.record.namespaces.UnmarshalNamespaceContext.getPrefix(UnmarshalNamespaceContext.java:58)
at org.eclipse.persistence.internal.oxm.record.UnmarshalRecordImpl.resolveNamespaceUri(UnmarshalRecordImpl.java:1338)
at org.eclipse.persistence.internal.oxm.SAXFragmentBuilder.startElement(SAXFragmentBuilder.java:78)
at org.eclipse.persistence.internal.oxm.XMLRelationshipMappingNodeValue.setupHandlerForKeepAsElementPolicy(XMLRelationshipMappingNodeValue.java:231)
at org.eclipse.persistence.internal.oxm.XMLAnyObjectMappingNodeValue.startElement(XMLAnyObjectMappingNodeValue.java:179)
at org.eclipse.persistence.internal.oxm.record.UnmarshalRecordImpl.startElement(UnmarshalRecordImpl.java:864)
at org.eclipse.persistence.internal.oxm.record.XMLStreamReaderReader.parseEvent(XMLStreamReaderReader.java:138)
at org.eclipse.persistence.internal.oxm.record.XMLStreamReaderReader.parse(XMLStreamReaderReader.java:102)
at org.eclipse.persistence.internal.oxm.record.XMLStreamReaderReader.parse(XMLStreamReaderReader.java:89)
at org.eclipse.persistence.internal.oxm.record.SAXUnmarshaller.unmarshal(SAXUnmarshaller.java:940)
at org.eclipse.persistence.internal.oxm.XMLUnmarshaller.unmarshal(XMLUnmarshaller.java:655)
at org.eclipse.persistence.jaxb.JAXBUnmarshaller.unmarshal(JAXBUnmarshaller.java:637)
at org.docx4j.convert.in.FlatOpcXmlImporter.<init>(FlatOpcXmlImporter.java:132)
When i add just these three to my plug-in bundle:
- Code: Select all
implementation group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.1'
implementation group: 'org.docx4j', name: 'docx4j-JAXB-ReferenceImpl', version: '8.2.8'
implementation group: 'javax.xml.stream', name: 'stax-api', version: '1.0-2'
i have:
- ClassCastException: com.ctc.wstx.stax.WstxInputFactory (loaded by sun.misc.Launcher$AppClassLoader@0x0000000100046e00)
cannot be cast to javax.xml.stream.XMLInputFactory
(loaded by org.apache.felix.framework.BundleWiringImpl$BundleClassLoader@0x0000000100240038)
(found matching super class javax.xml.stream.XMLInputFactory loaded by ,
but needed loader org.apache.felix.framework.BundleWiringImpl$BundleClassLoader@0x0000000100240038)
at javax.xml.stream.XMLInputFactory.newInstance(XMLInputFactory.java:136)
at org.docx4j.convert.in.FlatOpcXmlImporter.<init>(FlatOpcXmlImporter.java:115)
I really hope someone kindly help me out. All of this has to do with bundle class loading!
Original issue: https://stackoverflow.com/questions/669 ... der-docx4j