4

I use gradle-jaxb-plugin to generate classes from an XSD: https://github.com/jacobono/gradle-jaxb-plugin

It works fine with external binding and I can use the built-in XJC extensions without a problem. But I did not manage jaxb extension plugins to work, in particular -Xinheritance from the jaxb2-basics.

When I try the configuration proposed in the gradle-jaxb-plugin documentation, I get the following error:

:pwa-application:xjc FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':pwa-application:xjc'.
> java.util.ServiceConfigurationError: com.sun.tools.xjc.Plugin: Provider org.jvnet.jaxb2_commons.plugin.jaxbindex.JaxbIndexPlugin not a subtype

I have found the explanation in this thread: com.sun.tools.xjc.Plugin: Provider <plugin> not a subtype but there is no solution for gradle-jaxb-plugin there, I got stuck.

Community
  • 1
  • 1
Boris Maizel
  • 111
  • 1
  • 4

2 Answers2

7

Well, I can now answer my question by myself.

The solution is simply to use

taskClassname      = "org.jvnet.jaxb2_commons.xjc.XJC2Task"

It is mentioned in the documentation, but there is no explanation. Now I know what it is for.

Boris Maizel
  • 111
  • 1
  • 4
  • 3
    Could you elaborate a bit please? We are kind of stuck with similar issue. – darwinbaisa Aug 21 '15 at 11:33
  • Use XJC2Task instead of the default XJCTask: `jaxb { xsdDir = "some/folder" xjc { taskClassname = "com.sun.tools.xjc.XJC2Task" } }` – DLight May 19 '16 at 10:36
0

I faced with same error.
Project was using Java 11, but JAVA_HOME pointed to Java 8.

After I changed path in JAVA_HOME env. variable to Java 11, the issue was fixed.

Just for inforation - we are using Gradle and working XJC definition for Java 11 for us is following:

project.ant {
    taskdef name: "xjc",
            classname: "com.sun.tools.xjc.XJCTask",
            classpath: configurations.jaxb.asPath
    mkdir(dir: sourcesDir)
    mkdir(dir: classesDir)

    xjc(destdir: sourcesDir) {
        schema(dir: "src/main/resources/xsd", includes: "*.xsd", excludes: "XSD_FILENAME.xsd")
        arg(value: "-wsdl")
        arg(value: "-extension")
        arg(value: "-Xinheritance")
        arg(value: "-Xannotate")
        produces(dir: sourcesDir, includes: "**/*.java")
        binding(dir: "src/main/resources/xsd", includes: "bindings.xjb")
    }
}
Leonid Dashko
  • 3,657
  • 1
  • 18
  • 26