You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Randy Kamradt (JIRA)" <ji...@codehaus.org> on 2008/10/12 04:34:50 UTC

[jira] Commented: (MJAR-97) Using when you have no dependencies fails with FileNotFoundException

    [ http://jira.codehaus.org/browse/MJAR-97?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=150587#action_150587 ] 

Randy Kamradt commented on MJAR-97:
-----------------------------------

This appears to be a problem because it uses the maven project classpath, which starts with the classes directory.  Hacking the org.apache.maven.archiver.MavenArchiver to remove classpath entrys that end with 'classes' solves this.  But it doesn't answer the question of why it's only a problem if target/classes is the only dependency.  I'm attaching a patch of what I did in case anyone is interested.

> Using <addClasspath> when you have no dependencies fails with FileNotFoundException
> -----------------------------------------------------------------------------------
>
>                 Key: MJAR-97
>                 URL: http://jira.codehaus.org/browse/MJAR-97
>             Project: Maven 2.x Jar Plugin
>          Issue Type: Bug
>    Affects Versions: 2.2
>         Environment: Maven version: 2.0.8
> Java version: 1.6.0_01
> OS name: "windows xp" version: "5.1" arch: "x86" Family: "windows"
>            Reporter: Wim Deblauwe
>
> When you have no dependencies in your project and configure <addClasspath>true</addClasspath> for the jar plugin, then maven exits with a strange error message:
> {noformat}
> Embedded error: Problem creating jar: C:\personal\mytool\target\classes (Access is denied)
> {noformat}
> If I run with -e, you can see that the classes directory is trying to be opened like it is a file:
> {noformat}
> [INFO] Trace
> org.apache.maven.lifecycle.LifecycleExecutionException: Error assembling JAR
>         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:564)
>         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:480)
>         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:459)
>         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:311)
>         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:278)
>         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:143)
>         at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:333)
>         at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:126)
>         at org.apache.maven.cli.MavenCli.main(MavenCli.java:282)
>         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.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: org.apache.maven.plugin.MojoExecutionException: Error assembling JAR
>         at org.apache.maven.plugin.jar.AbstractJarMojo.createArchive(AbstractJarMojo.java:225)
>         at org.apache.maven.plugin.jar.AbstractJarMojo.execute(AbstractJarMojo.java:237)
>         at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:447)
>         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:539)
>         ... 16 more
> Caused by: org.codehaus.plexus.archiver.ArchiverException: Problem creating jar:
>  C:\personal\mytool\target\classes (Access is denied)
>         at org.codehaus.plexus.archiver.AbstractArchiver.createArchive(AbstractArchiver.java:690)
>         at org.apache.maven.archiver.MavenArchiver.createArchive(MavenArchiver.java:421)
>         at org.apache.maven.plugin.jar.AbstractJarMojo.createArchive(AbstractJarMojo.java:218)
>         ... 19 more
> Caused by: java.io.FileNotFoundException: C:\personal\mytool\target\classes (Access is denied)
>         at java.io.RandomAccessFile.open(Native Method)
>         at java.io.RandomAccessFile.<init>(RandomAccessFile.java:212)
>         at org.codehaus.plexus.archiver.zip.ZipFile.<init>(ZipFile.java:147)
>         at org.codehaus.plexus.archiver.zip.ZipFile.<init>(ZipFile.java:132)
>         at org.codehaus.plexus.archiver.jar.JarArchiver.grabFilesAndDirs(JarArchiver.java:922)
>         at org.codehaus.plexus.archiver.jar.JarArchiver.createIndexList(JarArchiver.java:499)
>         at org.codehaus.plexus.archiver.jar.JarArchiver.finalizeZipOutputStream(JarArchiver.java:422)
>         at org.codehaus.plexus.archiver.zip.AbstractZipArchiver.execute(AbstractZipArchiver.java:245)
>         at org.codehaus.plexus.archiver.AbstractArchiver.createArchive(AbstractArchiver.java:673)
>         ... 21 more
> {noformat}
> The workaround it to remove the <addClasspath/> thing ofcourse, but maven should give a better error message to avoid that people spend an hour searching for processes that keep the directory busy, when there is really a configuration problem.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira