When I use Maven to run unit tests for my Java EE application, I get a strange error: org.apache.maven.plugin.MojoExecutionException: cannot copy the artifact to the working directory caused by java.io.FileNotFoundException: D: \ Work \ Projets \ RT_GAF \ Dev \ Sandbox \ client \ target \ classes (access denied)
Maven application structure:
- ... \ Dev \ Sandbox \: the root of the application, this is the "pom" module, which lists other modules
- ... \ Dev \ Sandbox \ common \: 'jar', contains classes common to the client and server, and tests (JUnit only)
- ... \ Dev \ Sandbox \ client \: 'jar', contains smart client classes (Swing stuff, etc.) and tests (JUnit only) deployed via Java Web Start
- ... \ Dev \ Sandbox \ server \: 'jar' module, contains server classes (MVC, DAO stuff, etc.) and tests (both JUnit and Arquillian)
- ... \ Dev \ Sandbox \ webapp \: 'war' module, contains web elements (JSP, images, web.xml, etc.), absolutely NOT CLASSES OR TESTS, will receive "general" and "server", banks module
- ... \ Dev \ Sandbox \ application \: 'ear' containing application.xml will receive the war 'webapp'
As explained, we have JUnit and Arquillian tests.
The test "mvn test -Pjbossas-remote-6" (the profile is used for Arquillian tests to run tunnel tests in the container for JBoss 6) from the application root fails :
[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) -> [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.<init>(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
As you can see, the tests in the modules "common", "client" and "server" are executed correctly (yay!), But the test execution stops at the level of the "webapp" module, although this module does not contain absolutely any classes (no business classes , no tests).
Note that we can see Java Web Start links in the stack trace (" JnlpDownloadServletMojo ").
More surprisingly, the error mentions the path to the โclientโ module when the error occurs during the processing of the โwebappโ module.
If I try to run tests directly in the "webapp" module, it works fine (empty lines removed):
------------------------------------------------------- TESTS ------------------------------------------------------- There are no tests to run. Results : Tests run: 0, Failures: 0, Errors: 0, Skipped: 0 [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------
Do you guys know what's going on? Why do tests stop running? And how can I fix this?
Thank you for your time.
Hello