users@jaxb.java.net

RE: Java 6, JAXB, and XJC Plugins

From: Craig McIlwee <craig.mcilwee_at_openroadsconsulting.com>
Date: Mon, 18 May 2009 14:48:06 -0400

Thanks, moving my plugin to the com.sun.tools.xjc package and using the XJCFacade from the distribution you pointed to did the trick. I had seen mention of using 'java -jar jaxb-xjc.jar' before but was confused because the jaxb-xjc.jar I had didn't have a Main-class attribute in the manifest file and the XJC class didn't have a main method. Turns out that I had a version of the xjc jar that was bundled with hyperjaxb3 and it looks like they built a completely different version of the jar (even though it had the same version #). Replacing it with the jar from the jaxb site gave me one with the XJCFacade class that I needed to use at the command line.
 
In case anyone else runs across this, the command line that finally got things working is:
 
java -classpath jaxb-impl.jar;jaxb-xjc.jar;myPlugin.jar com.sun.tools.xjc.XJCFacade -d myOutputDir -b myBindingsFile.xml mySchemaDir
 
Craig
 
From: Wolfgang Laun [mailto:wolfgang.laun_at_gmail.com]
Sent: Monday, May 18, 2009 1:40 AM
To: users_at_jaxb.dev.java.net
Subject: Re: Java 6, JAXB, and XJC Plugins
 
You can download JAXB RI from jaxb.dev.java.net and use the xjc that comes with it. The runtime might still come from Java 6 SDK. I'm currently doing just this, using the provided code insertion plugin in combination with one of my own.

-W


On Mon, May 18, 2009 at 1:36 AM, McIlwee, Craig <craig.mcilwee_at_openroadsconsulting.com> wrote:
Hi,

We have been using a modified version of the code injection plugin for xjc in several projects for years and have had no issues. We are now trying to migrate to Java 6 and its causing a bit of trouble. From the reading I've done on this list and through google searching, I've concluded that it is not possible to use the ant XJCTask with java 6 because of the following error:

java.util.ServiceConfigurationError: com.sun.tools.xjc.Plugin: Provider com.orci.gateway.build.CodeInjector could not be instantiated: java.lang.ClassCastException

As a workaround I thought that I could use the xjc.exe bundled with the Java 6 SDK instead, so I put a branch in my build script that executes the XJCTask if compiled under java 5 or runs xjc through ant exec if java 6. This works fine for schemas that don't need the code injection plugin, but once I try to use the plugin I get a failure because of "unrecognized parameter -Xorci-inject". After reading through this list a bit more I found this post:

http://www.nabble.com/Re%3A-(JAXB-Plugin)-Customize-the-body-of-a-setter-method-to-fire-bound-properties-p8303769.html

which says that the xjc in java 6 doesn't support plugins and I'm shocked to hear this. Is it really true that xjc in java 6 doesn't support plugins? If so, are there any workarounds available?

Thanks,
Craig McIlwee