Maven test run error

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

+4
source share
4 answers

You control Maven 3, right? Have you recently updated Maven 2? One of your plugins was written for Maven 2 and not updated for 3. Maven 3 added support for resolving dependencies with modules in the reactor for the current build, which is a really nice feature, but that means the module dependency can now be resolved to the directory now instead jar files only. Plugins assuming dependencies are always jar files like this.

To illustrate, imagine that you have the modules foo and bar , which are both top-level modules, and bar depends on foo . With Maven 2, if you run mvn compile at the top-level , it will of course compile both foo and bar . What he will not do is compile bar on the foo version just compiled. In other words, if you just added a new method to the class in foo , and the class in bar uses it, you will get a compilation error by running mvn compile . This is because Maven 2 has the ability to allow artifacts from the repository, and since you did not install the new version of foo in the local repository, this method is not available for bar .

This was a rather annoying and highly requested change, so Maven 3 changes it. With mvn compile under Maven 3, ${project.build.outputDirectory} of foo will correspond to the resolution of dependencies in bar . With this approach, this mvn compile will work because the first foo compiled, and then when bar compiled, instead of the last foo jar, the local repo used uses foo/target/classes to satisfy which, of course, has the latest version of foo .

What you see is an old plugin that assumes - as it was in Maven 2 - all settings always allow files. In Maven 3, this is not always true.

+5
source

When looking at the error, it seems pretty obvious that the user running mvn does not have permission to access the D: \ Work \ Projets \ RT_GAF \ Dev \ Sandbox \ client \ target \ classes. Check access to files for reading and writing settings.

Another thing I can not say without seeing the pom files.

0
source

Please note that your directory has this file? Please check carefully.

As soon as I used ant , I have this problem too. Hope this helps you.

0
source

Run eclipse as an administrator. steps: Right-click on the eclipse and tell me how to start it as an administrator.

0
source

All Articles