users@jaxb2-commons.java.net

Re: [namespace-prefix] XJC Plugin causes ClassCastException

From: Luc <useyour.mind_at_gmail.com>
Date: Fri, 17 Aug 2012 12:52:09 +0200

Hello Manuel, and thanks for the fast reply ^^


> What is your context ? Are you using the plugin with ant (or with some
> Eclipse plugin) ?



The thread you linked above points to some classloader problem, so I
> suspect the context of what your trying to do is important.


I've downloaded namespace-prefix project source code, via anonymous SVN.
Then executed mvn compile jar:jar, which generates
jaxb2-namespace-prefix-1.2-SNAPSHOT.jar.
In my project, I use the XJC Ant Task in the following target:

<target name="generate-sources">
> <taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask">
> <classpath>
> <fileset dir="${jaxb.dir}" includes="*.jar" />
> <fileset dir="${namespace-prefix.dir}"
> includes="jaxb2-namespace-prefix-1.2-SNAPSHOT.jar" />
> </classpath>
> </taskdef>
> <xjc destdir="${build.sources.dir}"
> catalog="${src.resources.dir}/catalog/catalog.xml">
> <schema dir="${src.resources.dir}/schema"
> includes="saml-schema-protocol-2.0.xsd" />
> <binding dir="${src.resources.dir}/xjb" includes="saml-bindings.xjb" />
> <arg value="-extension" />
> <arg value="-Xnamespace-prefix" />
> </xjc>
> </target>


Where ${namespace-prefix.dir} to the previous generated .jar dir, and
${jaxb.dir} points to JAXB-2.1.13, but also tested with 2.2.6.
Later, I execute in a Windows command line: ant generate-sources -v, and
fails. Also I execute in Eclipse, and fails in the same way. Ant version is:

> Apache Ant version 1.8.1 compiled on April 30 2010


I don't know if I leave some more context information.

I could test if works with the maven-jaxb2-plugin, but I can't change Ant
script for the Maven one.

Thanks,
--
Lucas
2012/8/17 <manuel.siggen_at_vd.ch>
> Hi Luc,
>
>
> Luc <useyour.mind_at_gmail.com> a écrit sur 17.08.2012 09:35:57 :
>
>
> >
> > I've found the plugin namespace-prefix very useful.
>
>
> Cool, thanks !
>
> > But I found the
> > same error as told in http://www.java.net/node/676027
> > The only way of using it is re-compiling the com.sun.tools package,
> > which I don't think is how is "developed" (or it would be uploaded
> > with this package, right?).
>
> What is your context ? Are you using the plugin with ant (or with some
> Eclipse plugin) ?
>
> The thread you linked above points to some classloader problem, so I
> suspect the context of what your trying to do is important.
>
>
> >
> > My Java version:
> > java version "1.6.0_31"
> > Java(TM) SE Runtime Environment (build 1.6.0_31-b05)
> > Java HotSpot(TM) Client VM (build 20.6-b01, mixed mode, sharing)
>
> I'm using the same java version, but I use the 'namespace-prefix' plugin
> within the 'maven-jaxb2-plugin'.
>
> Let me know,
> Best regards,
>
>               Manuel
>
>
> ________________________________________*
> Manuel Siggen* - Ingénieur de développement logiciel
> Etat de Vaud, Département des Infrastructures et des Ressources Humaines
> (DIRH)
> Direction des Systèmes d'Information (DSI)
> Pôle Référentiels
> Avenue de Longemalle 1, CH-1020 Renens
> Tel:+41 (0)21 316 26 43 Fax:+41 (0)21 316 27 26 *
> **manuel.siggen@vd.ch* <manuel.siggen@vd.ch> - *www.vd.ch*<http://www.vd.ch/>
>