mojohaus / jaxb2-maven-plugin

JAXB2 Maven Plugin
https://www.mojohaus.org/jaxb2-maven-plugin/
Apache License 2.0
106 stars 77 forks source link

TransformerFactoryImpl was loaded incorrectly if xalan:xalan is in the classpath #49

Closed zhuchenwang closed 8 years ago

zhuchenwang commented 8 years ago

My project depends on xalan:xalan transitively. During SchemaGen, I got the following exception:

at org.codehaus.mojo.jaxb2.schemageneration.AbstractXsdGeneratorMojo.printSchemaGenCommandAndThrowException(AbstractXsdGeneratorMojo.java:888)
    at org.codehaus.mojo.jaxb2.schemageneration.AbstractXsdGeneratorMojo.performExecution(AbstractXsdGeneratorMojo.java:510)
    at org.codehaus.mojo.jaxb2.AbstractJaxbMojo.execute(AbstractJaxbMojo.java:257)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
    ... 20 more
Caused by: java.lang.IllegalArgumentException: Not supported: indent-number
    at org.apache.xalan.processor.TransformerFactoryImpl.setAttribute(TransformerFactoryImpl.java:574)
    at org.codehaus.mojo.jaxb2.schemageneration.XsdGeneratorHelper.getFactory(XsdGeneratorHelper.java:544)
    at org.codehaus.mojo.jaxb2.schemageneration.XsdGeneratorHelper.getHumanReadableXml(XsdGeneratorHelper.java:440)
    at org.codehaus.mojo.jaxb2.schemageneration.XsdGeneratorHelper.replaceNamespacePrefixes(XsdGeneratorHelper.java:302)
    at org.codehaus.mojo.jaxb2.schemageneration.AbstractXsdGeneratorMojo.performExecution(AbstractXsdGeneratorMojo.java:471)
    ... 23 more

I think it is caused by the META-INF/services/javax.xml.transform.TransformerFactory file inside xalan:xalan jar. it binds the implementation to org.apache.xalan.processor.TransformerFactoryImpl instead of com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.

Maybe you can consider this solution http://stackoverflow.com/questions/5447633/how-to-prevent-xalan-jar-that-has-meta-inf-services-javax-xml-transform-transfor

lennartj commented 8 years ago

This is a duplicate of #40.