'Missing JUNIT Jar Exception while building project using Maven
I am in the beginning phase of Maven. I created a project and was trying to use the command. what is missing at my end? I am trying to compile and run a TestSuite File:
mvn clean package
POM.xml
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test.myProject</groupId>
<artifactId>myTest</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>egdsvTest</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
but i get the below exception after using it.
Exception
D:\MVN_Shirish_Project\Test>mvn clean package
[INFO] Scanning for projects...
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethrea
ded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Test 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ Test ---
[INFO] Deleting D:\MVN_Shirish_Project\Test\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ Test
---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory D:\MVN_Shirish_Project\Test\src\
main\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ Test ---
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. b
uild is platform dependent!
[INFO] Compiling 1 source file to D:\MVN_Shirish_Project\Test\target\classe
s
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ eg
dsvTest ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory D:\MVN_Shirish_Project\Test\src\
test\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @
Test ---
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. b
uild is platform dependent!
[INFO] Compiling 1 source file to D:\MVN_Shirish_Project\Test\target\test-c
lasses
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ Test ---
[INFO] Surefire report directory: D:\MVN_Shirish_Project\Test\target\surefi
re-reports
[WARNING] Missing POM for org.apache.maven.surefire:surefire-junit3:jar:2.12.4
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.968 s
[INFO] Finished at: 2014-10-14T12:28:09+05:30
[INFO] Final Memory: 7M/247M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.
12.4:test (default-test) on project Test: Unable to generate classpath: org
.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException: Missing:
[ERROR] ----------
[ERROR] 1) org.apache.maven.surefire:surefire-junit3:jar:2.12.4
[ERROR]
[ERROR] Try downloading the file manually from the project website.
[ERROR]
[ERROR] Then, install it using the command:
[ERROR] mvn install:install-file -DgroupId=org.apache.maven.surefire -DartifactI
d=surefire-junit3 -Dversion=2.12.4 -Dpackaging=jar -Dfile=/path/to/file
[ERROR]
[ERROR] Alternatively, if you host your own repository you can deploy the file t
here:
[ERROR] mvn deploy:deploy-file -DgroupId=org.apache.maven.surefire -DartifactId=
surefire-junit3 -Dversion=2.12.4 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url
] -DrepositoryId=[id]
[ERROR]
[ERROR] Path to dependency:
[ERROR] 1) dummy:dummy:jar:1.0
[ERROR] 2) org.apache.maven.surefire:surefire-junit3:jar:2.12.4
[ERROR]
[ERROR] ----------
[ERROR] 1 required artifact is missing.
[ERROR]
[ERROR] for artifact:
[ERROR] dummy:dummy:jar:1.0
[ERROR]
[ERROR] from the specified remote repositories:
[ERROR] m1 (http://repo1.maven.org/maven2, releases=true, snapshots=false)
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionE
xception
Solution 1:[1]
Maven works by creating a local repository in your desktop or the machine you have installed maven and running this goal.
In the process of maven running the goal, it first tries to get all the dependent jar files from Central repository as you have listed in your comments M1 or M2 and then stores them under C:/Users/yourname/.m2/repository folder (assuming you are using a windows machine) or the corresponding user folder in other OS systems.
Then it uses the jars to run the build as required per the goals given.
Now in your case, you got to figure out a way to connect to the repositories (check your settings.xml located in the .m2 folder in your User directory) and check if you can connect to the internet central maven repositories. If not you can get the jar file and manually install them as advised in the error you have got. Once you do that I think you should get past this issue. Let me know if you still have the issues.
Solution 2:[2]
In my case, it was caused by me doing an offline build (i.e. mvn -o install
) and me not having that jar installed in my local Maven repository yet. Doing an online build (mvn install
) fixed it.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Raghav Vaidhyanathan |
Solution 2 |