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

JDK11, Unable to load source code of com.sun.tools.xjc.runtime.ZeroOneBooleanAdapter as a resource #152

Open
vercevales opened this issue Nov 6, 2019 · 3 comments

Comments

@vercevales
Copy link

vercevales commented Nov 6, 2019

Hi!

Having multiple XSD for SAML (official and standard XSDs) and trying to use them to generate classes I got an error:
Exception in thread "main" java.lang.InternalError: Unable to load source code of com.sun.tools.xjc.runtime.ZeroOneBooleanAdapter as a resource.

Digging deeper into the issue I have discovered that the missing resources were removed from
jaxb-xjc 2.3.2 (which is used in jaxb2-maven-plugin 2.5.0) whereas in jaxb-xjc 2.2.11 (which is used in jaxb2-maven-plugin 2.3.1) they are present.


POM's build section:
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>jaxb2-maven-plugin</artifactId> <version>2.5.0</version> <executions> <execution> <id>xjc</id> <goals> <goal>xjc</goal> </goals> </execution> </executions> <configuration> <sources> <source>${project.basedir}/src/main/resources/</source> </sources> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>11</source> <target>11</target> </configuration> </plugin> </plugins> </build>


mvn clean compile output (the classes are generated, but file ZeroOneBooleanAdapter.java is empty):
[INFO] ------------------------------------------------------------------------ Exception in thread "main" java.lang.InternalError: Unable to load source code of com.sun.tools.xjc.runtime.ZeroOneBooleanAdapter as a resource at com.sun.codemodel.fmt.JStaticJavaFile$ResourceLoader.getResourceAsStream(JStaticJavaFile.java:234) at com.sun.codemodel.fmt.JStaticJavaFile.build(JStaticJavaFile.java:84) at com.sun.codemodel.JPackage.build(JPackage.java:446) at com.sun.codemodel.JCodeModel.build(JCodeModel.java:327) at com.sun.codemodel.JCodeModel.build(JCodeModel.java:317) at com.sun.tools.xjc.Driver.run(Driver.java:384) at org.codehaus.mojo.jaxb2.javageneration.AbstractJavaGeneratorMojo.performExecution(AbstractJavaGeneratorMojo.java:475) at org.codehaus.mojo.jaxb2.AbstractJaxbMojo.execute(AbstractJaxbMojo.java:337) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288) at org.apache.maven.cli.MavenCli.main(MavenCli.java:199) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) at org.codehaus.classworlds.Launcher.main(Launcher.java:47)


when I downgrade the plugin to version
<groupId>org.codehaus.mojo</groupId> <artifactId>jaxb2-maven-plugin</artifactId> <version>2.3.1</version>

I get another error (and nothing is genrated in target directory):

[INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.codehaus.mojo:jaxb2-maven-plugin:2.3.1:xjc (xjc) on project adap-microservice-authentication-webapp: Execution xjc of goal org.codehaus.mojo:jaxb2-maven-plugin:2.3.1:xjc failed: A required class was missing while executing org.codehaus.mojo:jaxb2-maven-plugin:2.3.1:xjc: com/sun/codemodel/CodeWriter [ERROR] ----------------------------------------------------- [ERROR] realm = plugin>org.codehaus.mojo:jaxb2-maven-plugin:2.3.1 [ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy [ERROR] urls[0] = file:/home/pi26808/.m2/repository/org/codehaus/mojo/jaxb2-maven-plugin/2.3.1/jaxb2-maven-plugin-2.3.1.jar [ERROR] urls[1] = file:/home/pi26808/.m2/repository/javax/xml/bind/jaxb-api/2.2.11/jaxb-api-2.2.11.jar [ERROR] urls[2] = file:/home/pi26808/.m2/repository/org/glassfish/jaxb/jaxb-core/2.2.11/jaxb-core-2.2.11.jar [ERROR] urls[3] = file:/home/pi26808/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.2.11/jaxb-runtime-2.2.11.jar [ERROR] urls[4] = file:/home/pi26808/.m2/repository/org/glassfish/jaxb/jaxb-xjc/2.2.11/jaxb-xjc-2.2.11.jar [ERROR] urls[5] = file:/home/pi26808/.m2/repository/org/glassfish/jaxb/jaxb-jxc/2.2.11/jaxb-jxc-2.2.11.jar [ERROR] urls[6] = file:/home/pi26808/.m2/repository/com/thoughtworks/qdox/qdox/2.0-M3/qdox-2.0-M3.jar [ERROR] urls[7] = file:/home/pi26808/.m2/repository/org/sonatype/sisu/sisu-inject-bean/2.3.0/sisu-inject-bean-2.3.0.jar [ERROR] urls[8] = file:/home/pi26808/.m2/repository/org/sonatype/sisu/sisu-guice/3.1.0/sisu-guice-3.1.0-no_aop.jar [ERROR] urls[9] = file:/home/pi26808/.m2/repository/org/sonatype/sisu/sisu-guava/0.9.9/sisu-guava-0.9.9.jar [ERROR] urls[10] = file:/home/pi26808/.m2/repository/org/sonatype/aether/aether-util/1.13.1/aether-util-1.13.1.jar [ERROR] urls[11] = file:/home/pi26808/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.14/plexus-interpolation-1.14.jar [ERROR] urls[12] = file:/home/pi26808/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar [ERROR] urls[13] = file:/home/pi26808/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.3/plexus-sec-dispatcher-1.3.jar [ERROR] urls[14] = file:/home/pi26808/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar [ERROR] urls[15] = file:/home/pi26808/.m2/repository/org/codehaus/plexus/plexus-compiler-api/2.5/plexus-compiler-api-2.5.jar [ERROR] urls[16] = file:/home/pi26808/.m2/repository/org/codehaus/plexus/plexus-utils/3.0.22/plexus-utils-3.0.22.jar [ERROR] urls[17] = file:/home/pi26808/.m2/repository/org/sonatype/plexus/plexus-build-api/0.0.7/plexus-build-api-0.0.7.jar [ERROR] Number of foreign imports: 1 [ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]] [ERROR] [ERROR] -----------------------------------------------------: com.sun.codemodel.CodeWriter [ERROR] -> [Help 1]

@eriknellessen
Copy link

I have the same problem. I can reproduce both errors (with jaxb2-maven-plugin 2.5.0 and 2.3.1). Are there any known workarounds for this problem yet?

@eriknellessen
Copy link

As @vercevales already wrote, the problem is that jaxb-xjc 2.3.2 does not include the missing resources. It seems like this problem has already been fixed in jaxb-xjc in the following commit:
eclipse-ee4j/jaxb-ri@0042068

When using jaxb-xjc 2.3.3-b01 (the next version following 2.3.2), I ran into other problems. So I cloned jaxb-xjc, checked out the tag 2.3.2 and cherry-picked commit 0042068395f720bbe368762832e33ede1141f67a. I then installed jaxb-xjc and rebuilt my project. The problem with the missing ZeroOneBooleanAdapter file was gone.

@eriknellessen
Copy link

The corresponding issue in the jaxb-ri project is the following:
eclipse-ee4j/jaxb-ri#1287

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

No branches or pull requests

3 participants