users@jaxb.java.net

Re: JAXB compilation plugin

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Fri, 10 Feb 2006 10:20:28 -0800

Jonathan Johnson wrote:
> I resolved this one by downloading activation.jar (had to do it manually as
> Sun does not appear to permit automatic Maven 2 downloads, this is not
> good). After adding activation.jar to the repository the domino falls to
> this...

Ah, yes. JAXB2 API depends on a few other jars.

My understanding of the license is that it's OK to put those into a
Maven repository, as a part of your program (namely the plugin.) See

* License to Distribute Software. ... Sun
   grants you ... license to reproduce and distribute the
   Software in binary code form only, provided that
   you ... distribute the Software complete and
   unmodified and only bundled as part of your
   Programs,

So I guess that means you can't just redistribute this jar alone, but as
long as it's with other jars, it should be OK. In other words, I think I
can put this under the JAXB groupId. Not that it's ideal, but it should
work.

I'll ask internally, too.


> java.lang.NoClassDefFoundError: javax/xml/stream/XMLStreamException
> at
> com.sun.xml.bind.v2.runtime.JAXBContextImpl.createUnmarshaller(JAXBContextIm
> pl.java:607)
>
> Why are these extra jar(s) needed? The pom.xml is attached to show the
> current dependencies...

This is JSR-173 StAX API. The reason why we need those jars is because
JAXB API jar requires them. The reason why the API jar requires them is
because we (and the expert group) felt that it will improve the usability.

I think JSR-173 is on a Maven repository somewhere.

>
> Standard po schema is attached (I suspect its fine). The code is...
>
> XJC2Mojo xjc2Mojo = new XJC2Mojo(); // Derives from XJC2Task to
> resolve logging differences
> xjc2Mojo.setLogger(log);
> xjc2Mojo.setProject(new Project());
> xjc2Mojo.setDestdir(targetDirFile);
> xjc2Mojo.setSchema(schema);
> xjc2Mojo.execute(); // <-- throws class not found errors.

That's a good progress. Cool!

Any plan to commit this in the repository? You don't have to wait for it
to complete.

>
> -----Original Message-----
> From: Kohsuke Kawaguchi [mailto:kohsuke.kawaguchi_at_sun.com]
> Sent: Thursday, February 09, 2006 1:04 AM
> To: users_at_jaxb.dev.java.net
> Subject: Re: JAXB compilation plugin
>
>
> Jonathan Johnson wrote:
>> XJC2Task will not work because the code is tightly bound to the Ant
> classes
>> (see XJC2Task.getProject()).
>
> Yes, you are right that it's written for Ant.
>
> But on the other hand, it's surprisingly easy to drive Ant from any Java
> program. For example, in one of my hobby project Hudson, I use Ant's
> copy task [1]. Maven1 did it all the time (through Jelly.)
>
> So I think it's still possible to do this.
>
>> There are two Driver classes, I'm unclear on the difference between the
> two
>>
>> com.sun.tools.xjc.api.Driver
>> com.sun.tools.xjc.Driver
>>
>> In conclusion, I found that
>>
>> com.sun.tools.xjc.Driver.run(String[] args, XJCListener listener)
>>
>> will probably work the best.
>
> That said, I think this method would be also just fine.
>
> I'd mildly prefer for you to use the XJC2Task, because of the nice XML
> syntax it already offers, but that's more complicated.
>
> So I think your pick is sound --- and once you get started, and if you
> are interested, perhaps I could help to hook up XJC2Task into the maven
> plugin.
>
>
> [1]
> https://hudson.dev.java.net/source/browse/hudson/hudson/src/hudson/tasks/Art
> ifactArchiver.java?rev=1.2&view=markup
> --
> Kohsuke Kawaguchi
> Sun Microsystems kohsuke.kawaguchi_at_sun.com
>
>
> ------------------------------------------------------------------------
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net


-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com