title: Maven test execution error
body: <p>When I use Maven to run unit tests for my Java EE application, I get a strange error: <strong>org.apache.maven.plugin.MojoExecutionException: Unable to copy an artifact to the working directory</strong>
  caused by a <strong>java.io.FileNotFoundException: D:\Work\Projets\RT_GAF\Dev\Sandbox\client\target\classes (Access is denied)</strong></p>
  
  <p>The Maven structure of the application is :</p>
  
  <ul>
  <li>...\Dev\Sandbox\ : root of the application, this is a 'pom' module that lists the other modules
  <li>...\Dev\Sandbox\common\ : 'jar' module, contains classes common to the client and server, and tests (JUnit only)
  <li>...\Dev\Sandbox\client\ : 'jar' module, contains smart client side classes (Swing stuff, etc) and tests (JUnit only), deployed through Java Web Start
  <li>...\Dev\Sandbox\server\ : 'jar' module, contains server-side classes (MVC stuff, DAO, etc) and tests (both JUnit and Arquillian)
  <li>...\Dev\Sandbox\webapp\ : 'war' module, contains web items (JSP, images, web.xml, etc), ABSOLUTELY NO CLASSES OR TESTS, will receive the 'common' and 'server' jars
  <li>...\Dev\Sandbox\application\ : 'ear' module, contains application.xml, will receive the 'webapp' war
  </ul>
  
  <p>As explained, we have JUnit and Arquillian tests.  </p>
  
  <p>Test execution "mvn test -Pjbossas-remote-6" (the profile is used for Arquillian tests to tunnel in-container tests execution to JBoss 6) from the root of the application <strong>fails</strong>:</p>
  
  <pre><code>[INFO] ------------------------------------------------------------------------
  [INFO] Reactor Summary:
  [INFO] 
  [INFO] Sandbox ........................................... SUCCESS [0.003s]
  [INFO] Sandbox Common .................................... SUCCESS [45.003s]
  [INFO] Sandbox Client .................................... SUCCESS [20.226s]
  [INFO] Sandbox Server .................................... SUCCESS [49.064s]
  [INFO] Sandbox WebApp .................................... FAILURE [3.128s]
  [INFO] Sandbox Application ............................... SKIPPED
  [INFO] ------------------------------------------------------------------------
  [INFO] BUILD FAILURE
  [INFO] ------------------------------------------------------------------------
  [INFO] Total time: 1:57.663s
  [INFO] Finished at: Fri Oct 21 10:07:03 CEST 2011
  [INFO] Final Memory: 107M/478M
  [INFO] ------------------------------------------------------------------------
  [ERROR] Failed to execute goal org.codehaus.mojo.webstart:webstart-maven-plugin:1.0-beta-1:jnlp-download-servlet (default) on project sandbox-webapp: Unable to copy an artifact to the working directory: D:\Work\Projets\RT_GAF\Dev\Sandbox\client\target\classes (Access is denied) -&gt; [Help 1]
  org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo.webstart:webstart-maven-plugin:1.0-beta-1:jnlp-download-servlet (default) on project sandbox-webapp: Unable to copy an artifact to the working directory
      at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
      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:319)
      at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
      at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
      at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
      at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
      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:597)
      at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
      at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
      at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
      at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
  Caused by: org.apache.maven.plugin.MojoExecutionException: Unable to copy an artifact to the working directory
      at org.codehaus.mojo.webstart.JnlpDownloadServletMojo.retrieveJarResources(JnlpDownloadServletMojo.java:454)
      at org.codehaus.mojo.webstart.JnlpDownloadServletMojo.execute(JnlpDownloadServletMojo.java:136)
      at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
      at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
      ... 19 more
  Caused by: java.io.FileNotFoundException: D:\Work\Projets\RT_GAF\Dev\Sandbox\client\target\classes (Access is denied)
      at java.io.FileInputStream.open(Native Method)
      at java.io.FileInputStream.&lt;init&gt;(FileInputStream.java:106)
      at org.codehaus.plexus.util.FileUtils.copyFile(FileUtils.java:950)
      at org.codehaus.mojo.webstart.AbstractBaseJnlpMojo.copyJarAsUnprocessedToDirectoryIfNecessary(AbstractBaseJnlpMojo.java:569)
      at org.codehaus.mojo.webstart.JnlpDownloadServletMojo.retrieveJarResources(JnlpDownloadServletMojo.java:423)
      ... 22 more
  </code></pre>
  
  <p>As you can see, tests in 'common', 'client' and 'server' modules are executed correctly (yay !), but the tests execution stops at the 'webapp' module level even though this module contains absolutely no classes (no business classes, no tests).</p>
  
  <p>Note that we can see Java Web Start references in the stack trace ("<strong>JnlpDownloadServletMojo</strong>").</p>
  
  <p>More surprising, the error mentions <strong>a path of the 'client' module</strong> while the error happens during the processing of the 'webapp' module.</p>
  
  <p>If i try to execute the tests <strong>directly</strong> in the 'webapp' module, it <strong>works fine</strong> (blank lines removed) :</p>
  
  <pre><code>-------------------------------------------------------
   T E S T S
  -------------------------------------------------------
  There are no tests to run.
  Results :
  Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
  [INFO] ------------------------------------------------------------------------
  [INFO] BUILD SUCCESS
  [INFO] ------------------------------------------------------------------------
  </code></pre>
  
  <p>Do you guys known what is going on? Why does the tests execution stop? And how I can fix this?</p>
  
  <p>Thank you for your time.</p>
  
  <p>Regards</p>