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

Java class generation fails with java.lang.ClassNotFoundException: com.sun.xml.bind.v2.ContextFactory, when xjcVersion is set to 3.0.0 #21

Open
SantoshKumar4 opened this issue Jul 14, 2021 · 2 comments

Comments

@SantoshKumar4
Copy link

SantoshKumar4 commented Jul 14, 2021

My build.gradle is like this:
...
...
xjc {
xjcVersion.set("3.0.0")
xsdDir.set(layout.projectDirectory.dir("src/main/resources/xsd"))
defaultPackage.set("com.xx.xxx.xxxx.model")
}

$ ./gradlew xjc --info

_*** What went wrong:
Execution failed for task ':integration:lib:restvalidation:validationManager:xjc'.

A failure occurred while executing com.github.bjornvester.xjc.XjcWorker
jakarta.xml.bind.JAXBException: Implementation of Jakarta XML Binding-API has not been found on module path or classpath.
- with linked exception:
[java.lang.ClassNotFoundException: com.sun.xml.bind.v2.ContextFactory]**_

I am using 1.5.1 version.
classpath group: 'gradle.plugin.com.github.bjornvester', name:'xjc-gradle-plugin', version: '1.5.1'

The reason I want to use 3.0.0 version as I want to generate classes with jakarta imports.

If I don't use xjcVersion, then i don't see any issue but it creates files with javax.xml.bind.* and it's not compatible with other part of the code.
Can you please suggest why is it failing and is there anything else I need to do?

Command: C:\Java\java-11-openjdk-11.0.11.9-1.windows.redhat.x86_64\bin\java.exe --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.invoke=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.prefs/java.util.prefs=ALL-UNNAMED --add-opens java.prefs/java.util.prefs=ALL-UNNAMED --add-opens java.base/java.nio.charset=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.util.concurrent.atomic=ALL-UNNAMED -Xmx3072m -Dfile.encoding=windows-1252 -Duser.country=US -Duser.language=en -Duser.variant -cp C:\Users\xxxx.gradle\wrapper\dists\gradle-7.1-all\1esmmb218muptbc8q7pychb8t\gradle-7.1\lib\gradle-launcher-7.1.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 7.1

@davidyscott
Copy link

We had the same issue with Java 16, Gradle 7.1.1. Like @SantoshKumar4 we were able to get it to work with the default xjcVersion, but we would really like it to work with xjcVersion=3.0.1.

@fer-marino
Copy link

fer-marino commented Aug 24, 2021

I had to add this to make it working:

    xjc "org.glassfish.jaxb:jaxb-runtime:3.0.2"
    xjc 'org.glassfish.jaxb:jaxb-xjc:3.0.1'
    xjc 'jakarta.xml.bind:jakarta.xml.bind-api:3.0.1'
    xjc 'jakarta.annotation:jakarta.annotation-api:2.0.0'
    xjc 'jakarta.activation:jakarta.activation-api:2.0.1'

it would be nice anyway if this was documented somewhere or set it automatically

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