users@jaxb.java.net

Re: JDK 1.6, Ant and JAXB 2.1 Commons plugins: ClassCastException from com.sun.tools.xjc.Options.findServices

From: Andreas Loew <Andreas.Loew_at_Sun.COM>
Date: Tue, 10 Mar 2009 20:09:37 +0100

Hi Rama,

many thanks for your reply - turns out that I had completely forgotten
about the fork option when trying to work around this myself...

Rama Pulavarthi schrieb:

>> unfortunately, it looks like even after integration of JAXB 2.1 API
>> into JDK 1.6.0_04, there still seem to be some classloading issues
>> stopping me from using the JAXB2 Commons plugins running on JDK 1.6 in
>> an Ant-based scenario:
>>
> I don't think JDK 1.6.0_04 is the reason for this problem. JDK 1.6.0_04
> already has JAXB 2.1 API and if your standalone JAXB impl is in the
> classpath, you don't need to use endorsed mechansim with JDK 6u4.
> Standalone JAXB RI is tested to work with latest JDK 6 update releases.
>
> How are you defining your wsimport ant task in your project? Are you
> using fork option for wsimport?

My wsimport task has simply been autogenerated by NetBeans 6.1 wizard
(with the exception of me adding the JAXB plugin options) and looks like
the following:

         <taskdef name="wsimport" classname="com.sun.tools.ws.ant.WsImport">
             <classpath
path="${java.home}/../lib/tools.jar:${j2ee.platform.wsimport.classpath}:${javac.classpath}"/>
         </taskdef>

        (...)

         <wsimport xendorsed="true" verbose="true"
sourcedestdir="${build.generated.dir}/wsimport/service" extension="true"
destdir="${build.generated.dir}/wsimport/binaries"
wsdl="${basedir}/${conf-dir}xml-resources/web-services/TMF615Service/wsdl/TMF615_spmlv2_um_service.wsdl"
catalog="catalog.xml">
             <xjcarg value="-Xequals"/>
             <xjcarg value="-XhashCode"/>
             <xjcarg value="-XtoString"/>
         </wsimport>

I have now added fork="true" as the very first option to the wsimport
tag, and indeed, this did the trick for JDK 1.6... :-)

As I can now continue building my project without taking refuge to some
ugly workarounds like running NetBeans on JDK 1.5, I am happy again :-)))


But I'm still wondering why it failed before only on JDK 1.6 - Aleksei
was pointing to some classloader bug in the standard xjc plugin, so
maybe this is related!?

At least, the issue definitely is not related to NetBeans, because
building the project outside NetBeans on JDK 1.6 (without fork="true")
showed the same issue...


Many thanks for your help & best regards,

Andreas

-- 
Andreas Loew
Senior Java Architect
Sun Microsystems (Germany)