> -----Original Message-----
> From: KARR, DAVID
> Sent: Tuesday, January 20, 2015 8:35 AM
> To: users_at_jaxb.java.net
> Subject: Get "Provider xx not a subtype" when adding JAXB extension to XJC
>
> This is a variation of a question I asked last week, which I didn't get
> any response to.
>
> I can run XJC on a particular XSD and successfully generate classes. If I
> add to the classpath either of two particular JAXB extensions I'm trying
> to use, it fails with a stacktrace like the following:
> -----------------
> Exception in thread "main" java.util.ServiceConfigurationError:
> com.sun.tools.xjc.Plugin: Provider
> dk.conspicio.jaxb.plugins.XmlElementWrapperPlugin not a subtype
> at java.util.ServiceLoader.fail(ServiceLoader.java:231)
> at java.util.ServiceLoader.access$300(ServiceLoader.java:181)
> at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:369)
> at java.util.ServiceLoader$1.next(ServiceLoader.java:445)
> at com.sun.tools.xjc.Options.findServices(Options.java:924)
> -----------------
>
> I'm currently using a local copy of the "ElementWrapper" plugin and a
> reference to the "fluent API" plugin. If I remove the reference to the
> "ElementWrapper" plugin from the classpath, this error refers to the
> "fluent API" plugin.
>
> I'm adding references to the following jars in the classpath:
> * jaxb-xjc
> * jaxb-impl
> * jaxb-api
> * element wrapper jar
> * fluent api jar
> * activation-1.1.1.jar
> * jsr173 jar
>
> I'm currently using version 2.2.6 of the jaxb jars.
>
> I've tested this sequence in a shell script, just calling XJCFacade
> directly. I've tested this in an Ant build script, using the Ant XJC
> task. I've tested this in Gradle, using the same Ant XJC task. All of
> these fail with the same result.
>
> However, I've also tested this in Maven, using the "cxf-xjc-plugin" Maven
> plugin. This is working, processing the same schema and adding the same
> extensions. This has actually been working like this for quite a while,
> but I'm trying to convert this application build from Maven to Gradle.
> This obstacle is preventing this.
Ok. I have a solution to this. You can read about the basic solution at
http://stackoverflow.com/questions/27977479/com-sun-tools-xjc-plugin-provider-plugin-not-a-subtype .
Basically, the classpath provided for XJC has to be separated into two pieces. The jaxb-api, jaxb-core, and jaxb-xjc jars need to be provided to "load" or reference XJC, but the JAXB extension jars have to be loaded ONLY by XJC itself. You will likely see this error if the extension jars are loaded "too early".
So, if you're using XJCFacade, specify the "jaxb-" jars in the classpath parameter given to "java", but specify the extension jars in the classpath parameter for the "XJCFacade" class.