users@jaxb.java.net

Maven plugin and InvocationTargetException

From: Trond Andersen <trond.andersen_at_gmail.com>
Date: Fri, 5 Jan 2007 14:27:30 +0100

Hello

I've tried to use the maven plugin for JAXB and end up with an
exception. My plugin conifguration looks like this:

<plugin>
          <groupId>com.sun.tools.xjc.maven2</groupId>
          <artifactId>maven-jaxb-plugin</artifactId>
          <executions>
               <execution>
                   <goals>
                       <goal>generate</goal>
                   </goals>
               </execution>
           </executions>
           <configuration>
                <verbose>true</verbose>
           </configuration>
</plugin>

When trying to generate code for the schema I get the following exception:

[INFO] Compiling
file:/home/tronda/projects/htg/newsconductor/trunk/server/src/main/resources/nc.xsd
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] java.lang.reflect.InvocationTargetException
javax/activation/MimeTypeParseException
[INFO] ------------------------------------------------------------------------
[INFO] Trace
java.lang.Error: java.lang.reflect.InvocationTargetException
        at com.sun.tools.xjc.reader.Ring.get(Ring.java:77)
        at com.sun.tools.xjc.reader.xmlschema.BGMBuilder.<init>(BGMBuilder.java:105)
        at com.sun.tools.xjc.reader.xmlschema.BGMBuilder.build(BGMBuilder.java:75)
        at com.sun.tools.xjc.ModelLoader.annotateXMLSchema(ModelLoader.java:388)
        at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:145)
        at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:91)
        at com.sun.tools.xjc.XJC2Task._doXJC(XJC2Task.java:450)
        at com.sun.tools.xjc.XJC2Task.doXJC(XJC2Task.java:397)
        at com.sun.tools.xjc.XJC2Task.execute(XJC2Task.java:332)
        at com.sun.tools.xjc.maven2.XJCMojo.execute(XJCMojo.java:304)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:412)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:534)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:475)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:454)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:306)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:273)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:140)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:322)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:115)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:256)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
        at com.sun.tools.xjc.reader.Ring.get(Ring.java:66)
        ... 27 more
Caused by: java.lang.Error: java.lang.reflect.InvocationTargetException
        at com.sun.tools.xjc.reader.Ring.get(Ring.java:77)
        at com.sun.tools.xjc.reader.xmlschema.BindingComponent.getClassSelector(BindingComponent.java:25)
        at com.sun.tools.xjc.reader.xmlschema.ColorBinder.<init>(ColorBinder.java:24)
        at com.sun.tools.xjc.reader.xmlschema.BindGreen.<init>(BindGreen.java:23)
        ... 32 more
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
        at com.sun.tools.xjc.reader.Ring.get(Ring.java:66)
        ... 35 more
Caused by: java.lang.NoClassDefFoundError:
javax/activation/MimeTypeParseException
        at java.lang.Class.getDeclaredConstructors0(Native Method)
        at java.lang.Class.privateGetDeclaredConstructors(Class.java:2357)
        at java.lang.Class.getConstructor0(Class.java:2671)
        at java.lang.Class.getDeclaredConstructor(Class.java:1953)
        at com.sun.tools.xjc.reader.Ring.get(Ring.java:64)
        at com.sun.tools.xjc.reader.xmlschema.DefaultClassBinder.<init>(DefaultClassBinder.java:69)
        at com.sun.tools.xjc.reader.xmlschema.ClassSelector.<init>(ClassSelector.java:190)
        ... 40 more

The interesting part is the NoClassDefFoundError fir the
MimeTypeParseException. I haven't defined an classpath since it's my
opinion that this should be automatically handled by other POM's.

I've also tried to use the ANT task approach from within Maven, but
this fails with the same exception.

When running the xjc.sh script on the command line, it works and is
able to produce the source code.

Any pointers on where the problem is?


Best regards, Trond Andersen