I'm migrating from WAS to Liberty where in we are having JAXB as application dependency. I have extended the NamespaceMapper of the jaxb-impl and when I'm trying to set it to Marshaller Property I'm getting the error that the nampespace mapper should be instance of com.sun.xml.bind.marshaller.NamespacePrefixMapper and not of my custom namespace mapper.
public class MyNamespaceMapper extends com.sun.xml.bind.marshaller.NamespacePrefixMapper{
// custom logic.
}
JAXBContext context =JAXBContext.newInstance("class");
Marshaller marshaller = context.createMarshaller();
marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", new MyNamespaceMapper());
I have tried changing the delegation to parent last for the jaxb library but then I run into classloader issues. I tried using the ContextClassLoader but I keep running into the same issue. I tried creating the liberty user feature as well but I was unable run it correctly. Here is the maifest files of the feature I tried to create.
Feature-marshaller.MF
Subsystem-ManifestVersion: 1.0
Subsystem-SymbolicName: m-1.0.0; visibility:=public
Subsystem-Version: 1.0.0.qualifier
Subsystem-Type: osgi.subsystem.feature
Subsystem-Content: marshaller; version="[1,1.0.100)"
IBM-Feature-Version: 2
IBM-API-Package: com.sun.xml.bind.marshaller; type="api"
IBM-ShortName: m-1.0.0
MANIFEST.MF
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: marshaller
Bundle-SymbolicName: marshaller
Bundle-Version: 1.0.0
Import-Package: org.osgi.framework
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: com.sun.xml.bind.marshaller
Bundle-ClassPath: jaxb-impl-1.0.jar
I tried to create this OSGI bundle from the option create plugin from existing jar and I pointed to the jaxb jar. and then I created these Manifeyour text
st files.
Can someone please help me fix this issue?