dev@jaxb.java.net

Re: Unable to solve "Provider xx not a subtype" problem

From: David Karr <davidmichaelkarr_at_gmail.com>
Date: Thu, 29 Jan 2015 06:49:44 -0800

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.

On Wed, Jan 21, 2015 at 8:12 AM, David Karr <davidmichaelkarr_at_gmail.com>
wrote:

> This is not a proper subject for a "dev" list, but I've queried every
> other reasonable resource, with no result.
>
> I have a small app using CXF, JAX-RS, JAXB, along with two JAXB
> extensions, and Maven.
>
> I use the "cxf-xjc-plugin" in Maven, along with the "Element Wrapper" and
> "Fluent API" JAXB extensions, to generate a set of Java classes from a set
> of schemas. This works fine.
>
> I'm attempting to convert this build from Maven to Gradle. The key part
> is XJC and these JAXB extensions. Ever single way I've tried to run XJC
> fails with the following exception (the referenced classname varies
> depending on whether I leave in both JAXB extensions or remove one from my
> classpath):
>
> Caused by: java.util.ServiceConfigurationError: com.sun.tools.xjc.Plugin:
> Provider com.sun.tools.xjc.addon.xew.XmlElementWrapperPlugin not a subtype
> at com.sun.tools.xjc.Options.findServices(Options.java:957)
> at com.sun.tools.xjc.Options.getAllPlugins(Options.java:374)
> at com.sun.tools.xjc.Options.parseArgument(Options.java:688)
> at com.sun.tools.xjc.Options.parseArguments(Options.java:809)
> at com.sun.tools.xjc.XJC2Task._doXJC(XJC2Task.java:474)
> at com.sun.tools.xjc.XJC2Task.doXJC(XJC2Task.java:457)
> at com.sun.tools.xjc.XJC2Task.execute(XJC2Task.java:380)
> at com.sun.istack.tools.ProtectedTask.execute(ProtectedTask.java:103)
> at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
> at
> org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
>
> I've tried using the Ant XJC task from Gradle. I've tried it from an Ant
> "build.xml". I tried a Bash script directly calling the XJCFacade class.
> They all get the same result. I have the 2.2.7 version of the xjc, impl,
> and api jaxb jars in my classpath, along with the extension jars and other
> dependencies of those jars.
>
> I've posted about this on jaxb-user, ant-user, cxf-user (to ask why they
> think this only works with the cxf maven plugin), stackoverflow, and the
> issues page for the ElementWrapper plugin. The only response of any
> substance I got was indirectly from Martin Gainty, from my ant-user
> posting, where he talked a bit about how the "ServiceLoader" framework
> works. He didn't really provide a solution, but he implied that "Maven
> solves the issue by inheriting System CL at CLI before tacking on
> maven-core and any consequent plugins". I've tried some classpath ordering
> changes along those lines, but that doesn't help.
>
> Any useful information or leads would be appreciated.
>