Closed netzling closed 8 years ago
It appears that indent-number
is only accepted by Xalan in JDK 1.7 and 1.6, see http://stackoverflow.com/questions/15134861/java-lang-illegalargumentexception-not-supported-indent-number.
Setting the configuration property createJavaDocAnnotations
to false
avoids the problem, but is, of course, only a workaround.
I suppose we can handle this in the plugin by checking the JDK version, and applying the correct setting. If possible, we would need the same functionality to create human-readable comments (i.e. with indentation) even under JDK 8.
This issue also appears if you have transformSchemas, even if you turn off createJavaDocAnnotations, you will get this exception until you remove all transformSchemas.
The error is thrown from the following code snippet:
private static TransformerFactory getFactory() {
if (FACTORY == null) {
try {
FACTORY = TransformerFactory.newInstance();
// Harmonize XML formatting
FACTORY.setAttribute("indent-number", 2);
} catch (Throwable exception) {
// This should really not happen... but it seems to happen in some test cases.
throw new IllegalStateException("Could not acquire TransformerFactory implementation.", exception);
}
}
// All done.
return FACTORY;
}
... where the desired outcome is to provide a more sensible XSD formatting than if the indent-number argument was not provided. The "indent-number" parameter, in turn is found - along with the other accepted parameters - in the implementation of the TransformerFactory. The implementation found within the JDK8 (com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl
) does contain the constant - so I believe that you are using a TransformerFactory other than the JDK8 internal one.
However, a simple way to handle IllegalArgumentException is simply to catch it and move on. In case the TransformerFactory implementation does not support the indent-number attribute, the user will simply get a less well-formatted, generated XSD as a result.
When running schemagen from the command line (the 1.8 version) everything is fine, a schema is generated as expected. When the jaxb2-maven-plugin runs schemagen, it fails with a report that says that schemagen did not finish properly. Running maven with the -e flag I get the following cause:
POM sets java to 1.8:
The plugin is run like so:
Output with mvn -X -e compile:
Will attach the complete log.