jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Maven 2.x JAR Plugin
  • MJAR-97

Using <addClasspath> when you have no dependencies fails with FileNotFoundException

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Duplicate
  • Affects Version/s: 2.2
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:
    Maven version: 2.0.8
    Java version: 1.6.0_01
    OS name: "windows xp" version: "5.1" arch: "x86" Family: "windows"

Description

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:

Embedded error: Problem creating jar: C:\personal\mytool\target\classes (Access is denied)

If I run with -e, you can see that the classes directory is trying to be opened like it is a file:

[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

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.

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. Text File
    fix.patch
    11/Oct/08 9:35 PM
    2 kB
    Randy Kamradt

Issue Links

is duplicated by

Bug - A problem which impairs or prevents the functions of the product. MJAR-69 When 'index' and 'addClasspath' are both true, plugin fails.

  • Major - Major loss of function.
  • Closed - The issue is considered finished, the resolution is correct. Issues which are not closed can be reopened.

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Randy Kamradt added a comment - 11/Oct/08 9:34 PM

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.

Show
Randy Kamradt added a comment - 11/Oct/08 9:34 PM 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.
Hide
Permalink
Randy Kamradt added a comment - 11/Oct/08 9:35 PM

possible solution to this issue

Show
Randy Kamradt added a comment - 11/Oct/08 9:35 PM possible solution to this issue

People

  • Assignee:
    Unassigned
    Reporter:
    Wim Deblauwe
Vote (0)
Watch (0)

Dates

  • Created:
    23/Jan/08 7:29 AM
    Updated:
    28/Oct/09 1:18 PM
    Resolved:
    28/Oct/09 1:18 PM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.