1

I created a sample project with just a simple testng dependency. When i tried to compile it through terminal (via mvn compile), i got this error.

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.axatrikx.Test.AppTest
Exception in thread "ThreadedStreamConsumer" org.apache.maven.surefire.util.NestedRuntimeException: null; nested exception is org.apache.maven.surefire.report.ReporterException: Unable to create file for report: /home/amalbose/Workspace/Test/target/surefire-reports/com.axatrikx.Test.AppTest.txt (Permission denied); nested exception is java.io.FileNotFoundException: /home/amalbose/Workspace/Test/target/surefire-reports/com.axatrikx.Test.AppTest.txt (Permission denied)
org.apache.maven.surefire.report.ReporterException: Unable to create file for report: /home/amalbose/Workspace/Test/target/surefire-reports/com.axatrikx.Test.AppTest.txt (Permission denied); nested exception is java.io.FileNotFoundException: /home/amalbose/Workspace/Test/target/surefire-reports/com.axatrikx.Test.AppTest.txt (Permission denied)
java.io.FileNotFoundException: /home/amalbose/Workspace/Test/target/surefire-reports/com.axatrikx.Test.AppTest.txt (Permission denied)
    at java.io.FileOutputStream.open(Native Method)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:209)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:160)
    at java.io.FileWriter.<init>(FileWriter.java:90)
    at org.apache.maven.surefire.report.AbstractFileReporter.testSetStarting(AbstractFileReporter.java:74)
    at org.apache.maven.surefire.report.MulticastingReporter.testSetStarting(MulticastingReporter.java:44)
    at org.apache.maven.surefire.report.TestSetRunListener.testSetStarting(TestSetRunListener.java:104)
    at org.apache.maven.plugin.surefire.booterclient.output.ForkClient.consumeLine(ForkClient.java:94)
    at org.apache.maven.plugin.surefire.booterclient.output.ThreadedStreamConsumer$Pumper.run(ThreadedStreamConsumer.java:67)
    at java.lang.Thread.run(Thread.java:679)

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

[INFO] 
[INFO] --- maven-jar-plugin:2.3.2:jar (default-jar) @ Test ---
[INFO] 
[INFO] --- maven-install-plugin:2.3.1:install (default-install) @ Test ---
[INFO] Installing /home/amalbose/Workspace/Test/target/Test-0.0.1-SNAPSHOT.jar to /home/amalbose/.m2/repository/com/axatrikx/Test/0.0.1-SNAPSHOT/Test-0.0.1-SNAPSHOT.jar
[INFO] Installing /home/amalbose/Workspace/Test/pom.xml to /home/amalbose/.m2/repository/com/axatrikx/Test/0.0.1-SNAPSHOT/Test-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.328s
[INFO] Finished at: Tue May 15 23:03:42 IST 2012
[INFO] Final Memory: 5M/245M
[INFO] ------------------------------------------------------------------------

I am not using any surefire plugin. Here is my pom file.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.axatrikx</groupId>
    <artifactId>Test</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>Test</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.5.2</version>
        </dependency>
    </dependencies>
</project>

Please help me resolve this issue.

EDIT: I have given 777 permission on the entire workspace

4

1 回答 1

1

First make sure you are using maven-surefire-plugin in the correct version which doesn't look like:

Put into your pom:

 <build>
    ..
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.12</version>
        </plugin>
        ..
      </plugins>
    </pluginManagement>
   ..
 </build>
于 2012-05-17T12:17:40.060 回答