Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Websphere liberty EE8 gives errors on JAXB #409

Open
Celludriel opened this issue Aug 5, 2020 · 3 comments
Open

Websphere liberty EE8 gives errors on JAXB #409

Celludriel opened this issue Aug 5, 2020 · 3 comments

Comments

@Celludriel
Copy link

Hey,

We currently have a WebSphere traditional (8.5.5.9 java EE 6/java SE 7) running an application using docx4j v3.2.2 This application has been running for years without problems. We are currently migrating our application to WebSphere Liberty (20.0.0.8 java EE 8/java SE 8). WebSphere Liberty is a modular OSGI based application server. We tried several different versions of docx4j but they all seem to have problems running within the OSGI container.

Currently we are getting an exception in the following part of the docx4j code

	private static Object tryUsingRI(Marshaller m)
			throws JAXBException {
		try {
			Class c = Class.forName("org.docx4j.jaxb.ri.NamespacePrefixMapper");
			prefixMapper = c.newInstance();
			
			// Weird javax.xml.bind.PropertyException: property "com.sun.xml.bind.namespacePrefixMapper" 
			// must be an instance of type com.sun.xml.bind.marshaller.NamespacePrefixMapper, 
			// not org.docx4j.jaxb.ri.NamespacePrefixMapper
	        // at com.sun.xml.bind.v2.runtime.MarshallerImpl.setProperty(MarshallerImpl.java:502)
			// with ServiceMix 5.4.1 and org.apache.servicemix.bundles.jaxb-impl 2.2.11_1
			// Recommend you upgrade to ServiceMix 7.0.1, which works
			
			m.setProperty("com.sun.xml.bind.namespacePrefixMapper", prefixMapper );
			// Try RI suitable one
			log.info("Using ri.NamespacePrefixMapper, which is suitable for the JAXB RI");
			return prefixMapper;
		} catch (Exception e) {
			//log.error("JAXB: Can't instantiate JAXB Reference Implementation", e);
			throw new JAXBException("JAXB: Can't instantiate JAXB Reference Implementation", e);
		}
	}
javax.xml.bind.PropertyException: property "com.sun.xml.bind.namespacePrefixMapper" 
must be an instance of type com.sun.xml.bind.marshaller.NamespacePrefixMapper, not org.docx4j.jaxb.ri.NamespacePrefixMapper

We read the comment about ServiceMix but in our instance this does not apply. Is there anything we can do from a point of configuration of our maven setup or other setup that could solve our problem ?

@plutext
Copy link
Owner

plutext commented Aug 5, 2020

Did you see 2400fec

@Celludriel
Copy link
Author

Yes I did, but I have no idea how this karaf solution will help us with our websphere liberty situation. We decided to clone the repository and are attempting now to write a solution for liberty in NamespacePrefixMapperUtils. I'll keep this updated if we find a solution. If it's generic enough we could open a pull request to your main project.

@jluyten
Copy link

jluyten commented Aug 11, 2020

Fixed in #411

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants