users@jaxb.java.net

RE: Re: XJC error message

From: <HeruMartinus.Salim_at_infineon.com>
Date: Thu, 16 Nov 2006 11:47:43 +0100

> > After that I tried to extend the class SingleClass.
> > Here I added the enum of Messages hard-coded into this class.
> >
> > And still while parsing xml schema
> > I got an error message
> >
> > C:\UserData\salimher\testJava\plugin\build.xml:42:
> > java.lang.IllegalArgumentException: trying to create the same field
> > twice: addressUnit
>
> Obviously you're trying to create the same field within the
> defined class twice.
> Review your field renderer code.

The Problem, I didn't make any changes besides renaming the classname
and identifier to fit the extending renderer

>
> > But I have no idea why this happens, while I don't even get
> the line
> > number where this error caused.
> > This schema work fine when I don't override those XJC classes.
> >
> > Any idea?
> > Or can we show the line number causing the error using ant?
>
> Try -d -v.

Thanks, it worked. :-)

>
> I would also suggest that you implement (or use) some kind of
> test harness for plugins. When I develop plugins, I use
> maven-jaxb2-plugin-testing where I have stuff like
> RunXJC2Mojo. This allows executing plugins from within an IDE
> like Eclipse, with all debugging etc.
> Here's how a typical test class look like:
>
> public class RunToStringPlugin extends RunXJC2Mojo {
>
> @Override
> public File getSchemaDirectory() {
> return new File(getBaseDir(), "src/test/resources");
> }
>
> @Override
> protected void configureMojo(AbstractXJC2Mojo mojo) {
> // TODO Auto-generated method stub
> super.configureMojo(mojo);
> mojo.setForceRegenerate(true);
> }
>
> @Override
> public List<String> getArgs() {
> final List<String> args = new ArrayList<String>(super.getArgs());
> args.add("-XtoString");
> return args;
> }
> }
>
> RunXJC2Mojo is a JUnit test case, runnable from Eclipse.
>
> In the example above, schemas are loaded from
> src/test/resource, toString plugin is activated in getArgs().
>
> Bye.
> /lexi

Thanks also for this tips. Will try to use it.