Closed lennartj closed 9 years ago
This seems to stem from SchemaGen encountering incorrect JAXB annotations. Wrap the exception and dig out the correct error message.
SchemaGen's internals contains quite a few reflective method invocations and seemingly overloaded similar implementations. For one, these implementations internally add tools.jar
to classpath. Also, they seem to indicate that schemagen is somewhat poorly documented.
The root Exception's error message is
com.sun.tools.javac.api.JavacTrees cannot be cast to com.sun.source.util.Trees
The root Exception's full stack trace is
[ERROR] Displaying root cause Exception's stack trace ....
[ERROR]
[Exception]: java.lang.ClassCastException
[Message]: com.sun.tools.javac.api.JavacTrees cannot be cast to com.sun.source.util.Trees
com.sun.source.util.Trees.getJavacTrees(Trees.java:86)
com.sun.source.util.Trees.instance(Trees.java:77)
com.sun.tools.jxc.model.nav.ApNavigator.getLocation(ApNavigator.java:451)
com.sun.tools.jxc.model.nav.ApNavigator.getMethodLocation(ApNavigator.java:420)
com.sun.tools.jxc.model.nav.ApNavigator.getMethodLocation(ApNavigator.java:83)
com.sun.xml.bind.v2.model.impl.GetterSetterPropertySeed.getLocation(GetterSetterPropertySeed.java:118)
com.sun.xml.bind.v2.model.impl.PropertyInfoImpl.getLocation(PropertyInfoImpl.java:328)
com.sun.xml.bind.v2.runtime.IllegalAnnotationException.convert(IllegalAnnotationException.java:122)
com.sun.xml.bind.v2.runtime.IllegalAnnotationException.build(IllegalAnnotationException.java:106)
com.sun.xml.bind.v2.runtime.IllegalAnnotationException.<init>(IllegalAnnotationException.java:79)
com.sun.xml.bind.v2.model.impl.ClassInfoImpl.link(ClassInfoImpl.java:1275)
com.sun.xml.bind.v2.model.impl.ModelBuilder.link(ModelBuilder.java:454)
com.sun.tools.jxc.api.impl.j2s.JavaCompilerImpl.bind(JavaCompilerImpl.java:98)
com.sun.tools.jxc.ap.SchemaGenerator.process(SchemaGenerator.java:110)
com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794)
com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:705)
com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035)
com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176)
com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
com.sun.tools.javac.main.Main.compile(Main.java:523)
com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
com.sun.tools.jxc.SchemaGenerator$Runner.compile(SchemaGenerator.java:261)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:497)
com.sun.tools.jxc.SchemaGenerator.run(SchemaGenerator.java:166)
org.codehaus.mojo.jaxb2.schemageneration.AbstractXsdGeneratorMojo.performExecution(AbstractXsdGeneratorMojo.java:349)
org.codehaus.mojo.jaxb2.AbstractJaxbMojo.execute(AbstractJaxbMojo.java:248)
org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
org.apache.maven.cli.MavenCli.execute(MavenCli.java:582)
org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:497)
org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
The problem is that SchemaGenerator uses the ToolProvider.getSystemToolClassLoader()
to load certain classes from tools.jar.
When telling the local ClassRealm to use that class loader for certain packages, the problems disappear. While it was rather pesky to find the exact location of where the problem arose, ClassWorlds comes to the rescue ... although it was a fairly undocumented fix.
JAXB exceptions now appear in the standard plugin log. Fixed in 6057152
The
tools.jar
system dependency contains classes required for SchemaGen to work properly. The Tree class has thrown ClassCastExceptions for certain conditions. Validate with an IT that these problems are fixed.