4

I have a multi module project with a parent project A, and two childs project B and C. Project B has a dependency on project C. I use the maven-dependency-plugin to copy the dependencies of B to a lib/ directory in the target/ directory. So, I can use the maven-assembly-plugin to include this lib/ directory in the final zip. The problem is I get the following error when I run mvn clean package on project B:

at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) ... 19 more

Caused by: java.io.FileNotFoundException: D:\path-to-projects-directory\C\target\classes (Access is denied)

at java.io.FileInputStream.open(Native Method)

at java.io.FileInputStream.(FileInputStream.java:120)

at org.codehaus.plexus.util.io.FileInputStreamFacade.getInputStream(FileInputStreamFacade.java:36)

at org.codehaus.plexus.util.FileUtils.copyStreamToFile(FileUtils.java:1141)

at org.codehaus.plexus.util.FileUtils.copyFile(FileUtils.java:1048)

at org.apache.maven.plugin.dependency.AbstractDependencyMojo.copyFile(AbstractDependencyMojo.java:192) ... 23 more

Someone has an idea?

I've done some research on the web and I found that there is such an issue (see http://jira.codehaus.org/browse/MWAR-192 , that's for the wars but I have the similar problem with JAR). It seems that the target/classes directory of project C can't be accessed to create the C.jar (the C.jar must be included in the lib/ directory of project B).

Thanks

manash
  • 6,985
  • 12
  • 65
  • 125
  • sounds odd, why don't you just state your dependencies in your pom.xml's and let maven do the assembling? – definitely undefinable Jan 11 '12 at 22:57
  • Does it work standalone (outside Eclipse/m2eclipse)? – Raghuram Jan 12 '12 at 05:19
  • @definitelyundefinable I state the dependencies of project B in the POM of B. But, one of these dependencies is the project C and it must be packaged before to be included in the target/lib/ of B. And, when it tries to create C.jar, it needs to copy the target/classes to the JAR and it seems that target/classes can't be accessed. – manash Jan 12 '12 at 09:34
  • @Raghuram Outside Eclipse, I need to first deploy project C, but i don't like the fact that I need to deploy all my dependencies (in this case project C only, but may be more) before packaging the dependent project. So, I wanted to use Workspace resolution feature of the Eclipse Maven plugin (m2e). – manash Jan 12 '12 at 09:37

5 Answers5

4

I just ran into this issue as well using the configuration

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>2.3.2</version>
    <configuration>
        <archive>
            <index>true</index>
            <manifest>
                <addClasspath>true</addClasspath>
            </manifest>
            <manifestEntries>
                <mode>development</mode>
                <url>${project.url}</url>
                <key>value</key>
            </manifestEntries>
        </archive>
    </configuration>
    ...
</plugin>

provided from the manifest customization example at http://maven.apache.org/plugins/maven-jar-plugin/examples/manifest-customization.html. I diagnosed it to the <index>true</index> as the problem went away when that part was commented out, and verified that this was an issue for versions 2.3.2, 2.3.1, 2.3, 2.2, 2.1 of the maven jar plugin.

According to the maven plugin jira -- see https://jira.codehaus.org/browse/MJAR-69 -- it's just been fixed

Betlista
  • 10,327
  • 13
  • 69
  • 110
I-Lin Kuo
  • 3,220
  • 2
  • 18
  • 25
1

I just ran across this, the readOnly element apparently can cause an access denied message. The readOnly element is deprecated anyway, but I happened to use it from an older example.

1

I have the same issue.I have solved it in this way:

Right-click on traget folder > Properties > uncheck the Read-only option and tried problem solved.

enter image description here

4b0
  • 21,981
  • 30
  • 95
  • 142
Sri
  • 11
  • 1
0

i tried several things to resolve this problem:

  • changing permissions on the folder
  • removing the read-only attribute
  • deleting the folder from explorer
  • deleting the folder from elevated command prompt

no success.

Then i rebooted the machine and the target folder was magically gone.

Adrian C
  • 71
  • 3
0

The issue got resolved for me by just deleting the file from the eclipse problems view.

Attached the screenshot below.

Just right click on the error and click on Delete. This should fix it.

View Image

  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/30846189) – Nico Haase Jan 23 '22 at 10:00