title: Generating XSD schemas from JAXB types in Maven?
body: <p>I'm trying to basically generate XSD schemas from my model classes annotated in JAXB using a Maven plugin. Here's the relevant code in my POM:</p>
  
  <pre><code>&lt;plugin&gt;
      &lt;groupId&gt;com.sun.tools.jxc.maven2&lt;/groupId&gt;
      &lt;artifactId&gt;maven-jaxb-schemagen-plugin&lt;/artifactId&gt;
      &lt;version&gt;1.2&lt;/version&gt;
      &lt;executions&gt;
          &lt;execution&gt;
              &lt;phase&gt;generate-resources&lt;/phase&gt;
              &lt;goals&gt;
                  &lt;goal&gt;generate&lt;/goal&gt;
              &lt;/goals&gt;
          &lt;/execution&gt;
      &lt;/executions&gt;
  
      &lt;configuration&gt;
          &lt;project&gt;${project}&lt;/project&gt;
          &lt;destdir&gt;${project.build.directory}/schemas&lt;/destdir&gt;
          &lt;srcdir&gt;${project.build.sourceDirectory}/com/floodstream/wowza/mastercontrol/model&lt;/srcdir&gt;
          &lt;verbose&gt;true&lt;/verbose&gt;
      &lt;/configuration&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.xml.bind&lt;/groupId&gt;
              &lt;artifactId&gt;jaxb-api&lt;/artifactId&gt;
              &lt;version&gt;2.2&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.sun.xml.bind&lt;/groupId&gt;
              &lt;artifactId&gt;jaxb-xjc&lt;/artifactId&gt;
              &lt;version&gt;2.2&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.sun.xml.bind&lt;/groupId&gt;
              &lt;artifactId&gt;jaxb-impl&lt;/artifactId&gt;
              &lt;version&gt;2.2&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.sun.xml.bind&lt;/groupId&gt;
              &lt;artifactId&gt;jaxb-xjc&lt;/artifactId&gt;
              &lt;version&gt;2.2&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  &lt;/plugin&gt;
  
  &lt;!-- other stuff omitted for brevity --&gt;
  
  &lt;pluginRepository&gt;
      &lt;id&gt;maven-repository.dev.java.net&lt;/id&gt;
      &lt;name&gt;Java.net Maven 2 Repository&lt;/name&gt;
      &lt;url&gt;http://download.java.net/maven/2&lt;/url&gt;
  &lt;/pluginRepository&gt;
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>[ERROR] FATAL ERROR
  [INFO] ------------------------------------------------------------------------
  [INFO] org/apache/tools/ant/taskdefs/Javac
  org.apache.tools.ant.taskdefs.Javac
  [INFO] ------------------------------------------------------------------------
  [INFO] Trace
  java.lang.NoClassDefFoundError: org/apache/tools/ant/taskdefs/Javac
          at java.lang.ClassLoader.defineClass1(Native Method)
          at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
          at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
          at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
          at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
          at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
          at java.security.AccessController.doPrivileged(Native Method)
          at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
          at org.codehaus.classworlds.RealmClassLoader.loadClassDirect(RealmClassLoader.java:195)
          at org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassRealm.java:255)
          at org.codehaus.classworlds.RealmClassLoader.loadClass(RealmClassLoader.java:214)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
          at java.lang.ClassLoader.defineClass1(Native Method)
          at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
          at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
          at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
          at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
          at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
          at java.security.AccessController.doPrivileged(Native Method)
          at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
          at org.codehaus.classworlds.RealmClassLoader.loadClassDirect(RealmClassLoader.java:195)
          at org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassRealm.java:255)
          at org.codehaus.classworlds.RealmClassLoader.loadClass(RealmClassLoader.java:214)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
          at java.lang.ClassLoader.defineClass1(Native Method)
          at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
          at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
          at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
          at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
          at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
          at java.security.AccessController.doPrivileged(Native Method)
          at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
          at org.codehaus.classworlds.RealmClassLoader.loadClassDirect(RealmClassLoader.java:195)
          at org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassRealm.java:255)
          at org.codehaus.classworlds.RealmClassLoader.loadClass(RealmClassLoader.java:214)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
          at com.sun.tools.jxc.maven2.SchemaGenMojo.execute(SchemaGenMojo.java:143)
          at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
          at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
          at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
          at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
          at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
          at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
          at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
          at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
          at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
          at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
          at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:616)
          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.ClassNotFoundException: org.apache.tools.ant.taskdefs.Javac
          at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
          at java.security.AccessController.doPrivileged(Native Method)
          at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
          at org.codehaus.classworlds.RealmClassLoader.loadClassDirect(RealmClassLoader.java:195)
          at org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassRealm.java:255)
          at org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassRealm.java:274)
          at org.codehaus.classworlds.RealmClassLoader.loadClass(RealmClassLoader.java:214)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
          ... 59 more
  [INFO] ------------------------------------------------------------------------
  [INFO] Total time: 4 seconds
  [INFO] Finished at: Tue Aug 30 17:40:29 PDT 2011
  [INFO] Final Memory: 16M/170M
  [INFO] ------------------------------------------------------------------------
  </code></pre>