title: Maven: tools.jar not found when executing wsgen
body: <p>I try to use <code>jaxws:wsgen</code> maven plugin from Windows 8 command line, but it fails with:</p>
  
  <blockquote>
    <p>java.lang.ClassNotFoundException: com.sun.mirror.apt.AnnotationProcessorFactory</p>
  </blockquote>
  
  <p>I know this indicates Maven cannot find tools.jar in my JDK but I don't know how to add this (JDK is installed of course).</p>
  
  <p>Here are some details about my configuration:</p>
  
  <pre><code>echo %JAVA_HOME%
  C:\Java\jdk1.7.0_51
  
  java -version
  java version "1.7.0_51"
  Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
  Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
  
  mvn -version
  Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a; 2013-09-17 17:22:22+0200)
  Maven home: C:\Program Files (x86)\apache-maven-3.1.1
  Java version: 1.7.0_51, vendor: Oracle Corporation
  Java home: C:\Java\jdk1.7.0_51\jre
  Default locale: de_CH, platform encoding: Cp1252
  OS name: "windows 8", version: "6.2", arch: "amd64", family: "windows"
  </code></pre>
  
  <p>So I also tried to add a profile section to my pom.xml:</p>
  
  <pre><code>&lt;profiles&gt;
      &lt;profile&gt;
          &lt;id&gt;default-tools.jar&lt;/id&gt;
          &lt;activation&gt;
              &lt;property&gt;
                  &lt;name&gt;java.vendor&lt;/name&gt;
                  &lt;value&gt;Sun Microsystems Inc.&lt;/value&gt;
              &lt;/property&gt;
          &lt;/activation&gt;
          &lt;dependencies&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;com.sun&lt;/groupId&gt;
                  &lt;artifactId&gt;tools&lt;/artifactId&gt;
                  &lt;version&gt;1.7.0&lt;/version&gt;
                  &lt;scope&gt;system&lt;/scope&gt;
                  &lt;systemPath&gt;${java.home}/../lib/tools.jar&lt;/systemPath&gt;
              &lt;/dependency&gt;
          &lt;/dependencies&gt;
      &lt;/profile&gt;
  &lt;/profiles&gt;
  </code></pre>
  
  <p>and execute </p>
  
  <pre><code>mvn -P default-tools.jar package
  </code></pre>
  
  <p>but I still get the <code>ClassNotFoundException</code>.</p>
  
  <p>Full output:</p>
  
  <blockquote>
    <p>[ERROR] Failed to execute goal
    org.codehaus.mojo:jaxws-maven-plugin:1.10:wsgen (generate-wsdl) on
    project WebService: Failed to execute wsgen:
    com/sun/mirror/apt/AnnotationProcessorFactory:
    com.sun.mirror.apt.AnnotationProcessorFactory -> [Help 1]
    org.apache.maven.lifecycle.LifecycleExecutionException: Failed to
    execute goal org.codehaus.mojo:jaxws-maven-plugin:1.10:wsgen
    (generate-wsdl) on project WebService: Failed to execute wsgen
            at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
            at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
            at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
            at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
            at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
            at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
            at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
            at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
            at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
            at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
            at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
            at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
            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:606)
            at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
            at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
            at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
            at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
    Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to
    execute wsgen
            at org.codehaus.mojo.jaxws.AbstractWsGenMojo.execute(AbstractWsGenMojo.java:102)
            at org.codehaus.mojo.jaxws.MainWsGenMojo.execute(MainWsGenMojo.java:14)
            at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
            at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
            ... 19 more Caused by: java.lang.NoClassDefFoundError: com/sun/mirror/apt/AnnotationProcessorFactory
            at java.lang.ClassLoader.defineClass1(Native Method)
            at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
            at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
            at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
            at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
            at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
            at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
            at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(ClassRealm.java:389)
            at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:42)
            at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:259)
            at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:235)
            at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:227)
            at com.sun.tools.ws.WsGen.doMain(WsGen.java:69)
            at org.codehaus.mojo.jaxws.AbstractWsGenMojo.execute(AbstractWsGenMojo.java:97)
            ... 22 more Caused by: java.lang.ClassNotFoundException: com.sun.mirror.apt.AnnotationProcessorFactory
            at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
            at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:259)
            at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:235)
            at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:227)
            ... 38 more</p>
  </blockquote>
  
  <p>Also putting the <code>tools.jar</code> into my local repository did not solve my problem.</p>
  
  <p>Does anybody has an idea what to try next?</p>
  
  <p>Thanks!</p>