ChatGPT解决这个技术问题 Extra ChatGPT

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.10:test

I have scoured the internet for almost five days now looking for a fix to this issue, but I cannot seem to find and fix it on my own, mainly because I am so new to both Maven and PlayN so I'm not entirely sure at what I'm looking at exactly. But, it is clearly fizzing up at building the core. Seems it can't download an "artifact filter", and is unable to run Surefire's test. But, I'm just speculating on things I don't quite understand fully, even though I've been trying to research these things like crazy. Any help from more experienced people would be very, very, appreciated. I'm losing my mind on this.

[INFO] Building Synthesis Core 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ synthesis-core ---
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ synthesis-core ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] skip non existing resourceDirectory C:\Users\Josiah\synthesis\core\src\main\resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3:compile (default-compile) @ synthesis-core ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ synthesis-core ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\Josiah\synthesis\core\src\test\resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3:testCompile (default-testCompile) @ synthesis-core ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.10:test (default-test) @ synthesis-core ---
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-common-artifact-filters/1.3/maven-common-artifact-filters-1.3.pom
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] Synthesis Metaproject ............................. SUCCESS [1.059s]
[INFO] Synthesis Core .................................... FAILURE [3.538s]
[INFO] Synthesis Java .................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.997s
[INFO] Finished at: Wed Oct 31 23:57:38 EDT 2012
[INFO] Final Memory: 6M/109M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.10:test (default-test) on project synthesis-core: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.10:test failed: Plugin org.apache.maven.plugins:maven-surefire-plugin:2.10 or one of its dependencies could not be resolved: Failed to collect dependencies for org.apache.maven.plugins:maven-surefire-plugin:jar:2.10 (): Failed to read artifact descriptor for org.apache.maven.shared:maven-common-artifact-filters:jar:1.3: Could not transfer artifact org.apache.maven.shared:maven-common-artifact-filters:pom:1.3 from/to central (http://repo.maven.apache.org/maven2): Remotely Closed [id: 0x0847a8f3, /192.168.1.54:65153 :> repo.maven.apache.org/93.184.215.223:80] -> [Help 1]

I then had it to print the whole debug logging, and it elaborated a bit on the Surefire bit, displaying all of the Exceptions invoked:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.
10:test (default-test) on project synthesis-core: Execution default-test of goal
 org.apache.maven.plugins:maven-surefire-plugin:2.10:test failed: Plugin org.apa
che.maven.plugins:maven-surefire-plugin:2.10 or one of its dependencies could no
t be resolved: Failed to collect dependencies for org.apache.maven.plugins:maven
-surefire-plugin:jar:2.10 (): Failed to read artifact descriptor for org.apache.
maven.shared:maven-common-artifact-filters:jar:1.3: Could not transfer artifact
org.apache.maven.shared:maven-common-artifact-filters:pom:1.3 from/to central (h
ttp://repo.maven.apache.org/maven2): Connection reset -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal o
rg.apache.maven.plugins:maven-surefire-plugin:2.10:test (default-test) on projec
t synthesis-core: Execution default-test of goal org.apache.maven.plugins:maven-
surefire-plugin:2.10:test failed: Plugin org.apache.maven.plugins:maven-surefire
-plugin:2.10 or one of its dependencies could not be resolved: Failed to collect
 dependencies for org.apache.maven.plugins:maven-surefire-plugin:jar:2.10 ()
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:225)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:84)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:59)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBu
ild(LifecycleStarter.java:183)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(Lifecycl
eStarter.java:161)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Laun
cher.java:290)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.jav
a:230)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(La
uncher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:
352)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-t
est of goal org.apache.maven.plugins:maven-surefire-plugin:2.10:test failed: Plu
gin org.apache.maven.plugins:maven-surefire-plugin:2.10 or one of its dependenci
es could not be resolved: Failed to collect dependencies for org.apache.maven.pl
ugins:maven-surefire-plugin:jar:2.10 ()
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(Default
BuildPluginManager.java:82)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:209)
        ... 19 more
Caused by: org.apache.maven.plugin.PluginResolutionException: Plugin org.apache.
maven.plugins:maven-surefire-plugin:2.10 or one of its dependencies could not be
 resolved: Failed to collect dependencies for org.apache.maven.plugins:maven-sur
efire-plugin:jar:2.10 ()
        at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.re
solve(DefaultPluginDependenciesResolver.java:211)
        at org.apache.maven.plugin.internal.DefaultMavenPluginManager.createPlug
inRealm(DefaultMavenPluginManager.java:353)
        at org.apache.maven.plugin.internal.DefaultMavenPluginManager.setupPlugi
nRealm(DefaultMavenPluginManager.java:321)
        at org.apache.maven.plugin.DefaultBuildPluginManager.getPluginRealm(Defa
ultBuildPluginManager.java:175)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(Default
BuildPluginManager.java:78)
        ... 20 more
Caused by: org.sonatype.aether.collection.DependencyCollectionException: Failed
to collect dependencies for org.apache.maven.plugins:maven-surefire-plugin:jar:2
.10 ()
        at org.sonatype.aether.impl.internal.DefaultDependencyCollector.collectD
ependencies(DefaultDependencyCollector.java:258)
        at org.sonatype.aether.impl.internal.DefaultRepositorySystem.collectDepe
ndencies(DefaultRepositorySystem.java:308)
        at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.re
solve(DefaultPluginDependenciesResolver.java:199)
        ... 24 more
Caused by: org.sonatype.aether.resolution.ArtifactDescriptorException: Failed to
 read artifact descriptor for org.apache.maven.shared:maven-common-artifact-filt
ers:jar:1.3
        at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.
loadPom(DefaultArtifactDescriptorReader.java:296)
        at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.
readArtifactDescriptor(DefaultArtifactDescriptorReader.java:186)
        at org.sonatype.aether.impl.internal.DefaultDependencyCollector.process(
DefaultDependencyCollector.java:412)
        at org.sonatype.aether.impl.internal.DefaultDependencyCollector.process(
DefaultDependencyCollector.java:544)
        at org.sonatype.aether.impl.internal.DefaultDependencyCollector.collectD
ependencies(DefaultDependencyCollector.java:240)
        ... 26 more
Caused by: org.sonatype.aether.resolution.ArtifactResolutionException: Could not
 transfer artifact org.apache.maven.shared:maven-common-artifact-filters:pom:1.3
 from/to central (http://repo.maven.apache.org/maven2): Connection reset
        at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolve(Def
aultArtifactResolver.java:538)
        at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArti
facts(DefaultArtifactResolver.java:216)
        at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArti
fact(DefaultArtifactResolver.java:193)
        at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.
loadPom(DefaultArtifactDescriptorReader.java:281)
        ... 30 more
Caused by: org.sonatype.aether.transfer.ArtifactTransferException: Could not tra
nsfer artifact org.apache.maven.shared:maven-common-artifact-filters:pom:1.3 fro
m/to central (http://repo.maven.apache.org/maven2): Connection reset
        at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(W
agonRepositoryConnector.java:951)
        at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(W
agonRepositoryConnector.java:941)
        at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$GetTask.
run(WagonRepositoryConnector.java:669)
        at org.sonatype.aether.util.concurrency.RunnableErrorForwarder$1.run(Run
nableErrorForwarder.java:60)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
utor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:908)
        at java.lang.Thread.run(Thread.java:662)
Caused by: org.apache.maven.wagon.TransferFailedException: Connection reset
        at org.apache.maven.wagon.shared.http4.AbstractHttpClientWagon.fillInput
Data(AbstractHttpClientWagon.java:799)
        at org.apache.maven.wagon.StreamWagon.getInputStream(StreamWagon.java:11
6)
        at org.apache.maven.wagon.StreamWagon.getIfNewer(StreamWagon.java:88)
        at org.apache.maven.wagon.StreamWagon.get(StreamWagon.java:61)
        at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$GetTask.
run(WagonRepositoryConnector.java:601)
        ... 4 more
Caused by: java.net.SocketException: Connection reset
        at java.net.SocketInputStream.read(SocketInputStream.java:168)
        at org.apache.maven.wagon.providers.http.httpclient.impl.io.AbstractSess
ionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:149)
        at org.apache.maven.wagon.providers.http.httpclient.impl.io.SocketInputB
uffer.fillBuffer(SocketInputBuffer.java:110)
        at org.apache.maven.wagon.providers.http.httpclient.impl.io.AbstractSess
ionInputBuffer.readLine(AbstractSessionInputBuffer.java:264)
        at org.apache.maven.wagon.providers.http.httpclient.impl.conn.DefaultRes
ponseParser.parseHead(DefaultResponseParser.java:98)
        at org.apache.maven.wagon.providers.http.httpclient.impl.io.AbstractMess
ageParser.parse(AbstractMessageParser.java:252)
        at org.apache.maven.wagon.providers.http.httpclient.impl.AbstractHttpCli
entConnection.receiveResponseHeader(AbstractHttpClientConnection.java:281)
        at org.apache.maven.wagon.providers.http.httpclient.impl.conn.DefaultCli
entConnection.receiveResponseHeader(DefaultClientConnection.java:247)
        at org.apache.maven.wagon.providers.http.httpclient.impl.conn.AbstractCl
ientConnAdapter.receiveResponseHeader(AbstractClientConnAdapter.java:219)
        at org.apache.maven.wagon.providers.http.httpclient.protocol.HttpRequest
Executor.doReceiveResponse(HttpRequestExecutor.java:298)
        at org.apache.maven.wagon.providers.http.httpclient.protocol.HttpRequest
Executor.execute(HttpRequestExecutor.java:125)
        at org.apache.maven.wagon.providers.http.httpclient.impl.client.DefaultR
equestDirector.tryExecute(DefaultRequestDirector.java:645)
        at org.apache.maven.wagon.providers.http.httpclient.impl.client.DefaultR
equestDirector.execute(DefaultRequestDirector.java:464)
        at org.apache.maven.wagon.providers.http.httpclient.impl.client.Abstract
HttpClient.execute(AbstractHttpClient.java:820)
        at org.apache.maven.wagon.providers.http.httpclient.impl.client.Abstract
HttpClient.execute(AbstractHttpClient.java:754)
        at org.apache.maven.wagon.shared.http4.AbstractHttpClientWagon.execute(A
bstractHttpClientWagon.java:674)
        at org.apache.maven.wagon.shared.http4.AbstractHttpClientWagon.fillInput
Data(AbstractHttpClientWagon.java:793)
        ... 8 more

EDIT: Adding in my pom.xml for analysis.

<?xml version="1.0" encoding="UTF-8"?>
<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>
  <parent>
    <groupId>com.googlecode.playn</groupId>
    <artifactId>playn-project</artifactId>
    <version>1.3.1</version>
  </parent>

  <groupId>com.hijackedlongboat</groupId>
  <artifactId>synthesis</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>pom</packaging>
  <name>Synthesis Metaproject</name>

  <properties>
    <playn.version>1.3.1</playn.version>
  </properties>

  <profiles>
    <profile>
      <id>java</id>
      <activation><activeByDefault>true</activeByDefault></activation>
      <modules><module>java</module></modules>
    </profile>
    <profile>
      <id>android</id>
      <modules><module>android</module></modules>
    </profile>
    <profile>
      <id>ios</id>
      <modules><module>ios</module></modules>
    </profile>
    <profile>
      <id>html</id>
      <modules><module>html</module></modules>
    </profile>
    <profile>
      <id>flash</id>
      <modules><module>flash</module></modules>
    </profile>
  </profiles>

  <modules>
    <module>core</module>
  </modules>
</project>

EDIT 2: RESOLVED Through using the command "mvn dependency::tree" I was able to find a missing repository that wasn't being displayed on the debug and stack trace. The missing repository was "forplay-legacy", which I then added to the pom.xml as follows:

  <repositories>
    <repository>
      <id>forplay-legacy</id>
      <url>http://forplay.googlecode.com/svn/mavenrepo</url>
    </repository>
  </repositories>
Show us the most important part, your pom.xml. Then we might be able to help.
My pom. You've got it kind sir. Editing my post now to add it in.
@user1784668 how do we know which one is missing?
mvn install solve the problem for me, it installs all the dependancies
ugh, in case you are getting a similar error in a spring boot build, and you get some testcases mysteriously skipped, check this answer about default junit exclusions that get into the default pom.xml files that circulate out there stackoverflow.com/a/60831916/57033

P
Pratik Goenka

I had similar issue, I was able to solve it using -U option along with mvn command as

mvn clean install -U

This worked for me, hope it helps.


what does -U do?
@Spikolynn, -U re-downloads all of the dependencies
Using Eclipse : Right click on project > Run as > maven clean..This worked for me
z
zb226

You're probably missing some dependencies.

Locate the dependencies you're missing with mvn dependency:tree, then install them manually, and build your project with the -o (offline) option.


I can't imagine what trouble my laptop is having connecting to the internet from my own home wifi. My firewall is also off under my secure router. Though, you make a valid point, so I'm going to definitely give it a shot, and I'll write back with the results.
Oh my god, thank you so much. It wasn't a problem with my internet, but "mvn dependency::tree" command that I hadn't known before you told it to me in your comment led me to find a missing repository that the debug and stack trace commands weren't showing me. The missing repository was "forplay-legacy". I then did some googling on this repository, and found some information on it, then I added it to my list of repositories. And, voila, it installed properly. I would have never found it had you not mentioned that command. Thank you very much!
Well!! This trick helped me too. I don't know why UI (Maven -> Update Project) dint help me.
Haha, I completely forgot I had -o and my snapshots wouldn't update. Thanks for the reminder!
Pratik's answer below, mvn clean install -U, is a much easier fix.
C
Community

I had a similar problem but all answers here didn't help me.

For me the problem was a failing test. If you are doing test driven development, then a failing or not implemented test shouldn't break the build. I still want my project to build.

To solve this, I added a configuration to surefire so that it ignores a failing test.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.19.1</version>
    <configuration>
        <testFailureIgnore>true</testFailureIgnore>
    </configuration>
</plugin>

I don't think this is a good idea. Changes are this get's checked into SCM and then your CI server won't catch errors in your code.
@britter It doesn't mean it ignores errors (failing tests). It only doesn't break the build when a test fails. With test driven style this is also okay on the CI server. You still can perform what ever you like on failing tests and see which tests failed.
It's totally false like answer : it's not allowing testFailure that will resolve the problem
This will reduce the coverage of your test cases, which could be dangerous! It makes the errors disappear but doesn't solve the problem.
a
avp

This error occurs if some unit test cases are failing.

In my application, certain unit tests were not compatible with Java 8 so they were failing. My error was resolved after changing jdk1.8.0_92 to jdk1.7.0_80.

The build would succeed with mvn clean install -DskipTests but this will skip the unit tests. So just ensure that you run then separately after the build is complete.


Yes, this is true for me too. The test cases are failing and thus we get the mentioned error
J
Jamal

Update the Maven project:

Steps:

Right-click on "project" Go to "Maven" >> "Update" Wait for all the changes to be applied Commit the changes (if code is on repo) Run


C
Chihab

I tried following instructions given in most of the comments on this thread, including the chosen answer but the error persisted. I did some research and found this page that gave a solution that helped me out (okay, with some guessing though of my part).

So what I did is that I replaced the version number in the maven surefire plugin as follows: <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>3.0.0-M1</version>

I hope this helps!


D
Dipu

I faced the same error, but in my case, the problem was resolved after deleting the /target folder and nbactions.xml file.


In my case - just delete /target folder from high level folder and all subfolders did the trick.
T
Taisbevalle

I had same issue, I resolved from below steps:

Right click on project->maven->Update project Here I selected "force update for snapshot/release" After that I compiled again my project and issue got fixed


w
whirlwin

When I encountered the problem, the changes.xml document was malformed (missing an end tag). The fix was to edit the XML to make it well formed.

So checking that the XML is well formed can be important, especially when the release plugin does not complain about it.


A
Anuja Lamahewa

For me changing the Jenkins version helped.

  <parent>
    <groupId>org.jenkins-ci.plugins</groupId>
    <artifactId>plugin</artifactId>
    <version>1.642.4</version><!-- which version of Jenkins is this plugin built against? -->
  </parent>

M
Manav Sharma

Sometimes you get similar sounding errors but for reasons that're really not related to the tools - in this case Surefire plugin.

For me I was getting a similar error but the reason was i wasn't pointing to the correct DB url !

Among a lot of verbosity (using mvn -X flag) I saw a timeout message.

One trick I did was to install IntelliJ on the build server (for debugging purpose) and fixing problems through it first and then uninstalling it and making sure everything works on build server as well.


s
shiv

https://i.stack.imgur.com/If9tS.png

Or

Navigate to project root folder and use following commands :

mvn clean install -U or mvn clean install --update-snapshots

Here -U will Forces a check for missing releases and updated snapshots on remote repositories


L
Leonardo Alves Machado

I had a similar problem, and the solution for me was quite different from what the other users posted.

The problem with me was related to the project I was working last year, which required a certain proxy on maven settings (located at <path to maven folder>\maven\conf\settings.xml and C:\Users\<my user>\.m2\settings.xml). The proxy was blocking the download of required external packages.

The solution was to put back the original file (settings.xml) on those places. Once things were restored, I was able to download the packages and everything worked.


o
oitathi

please follow this tutorial: https://www.petrikainulainen.net/programming/maven/creating-code-coverage-reports-for-unit-and-integration-tests-with-the-jacoco-maven-plugin/

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.15</version>
<configuration>
    <!-- Sets the VM argument line used when unit tests are run. -->
    <argLine>${surefireArgLine}</argLine>
    <!-- Skips unit tests if the value of skip.unit.tests property is true -->
    <skipTests>${skip.unit.tests}</skipTests>
    <!-- Excludes integration tests when unit tests are run. -->
    <excludes>
        <exclude>**/IT*.java</exclude>
    </excludes>
</configuration>


关注公众号,不定期副业成功案例分享
Follow WeChat

Success story sharing

Want to stay one step ahead of the latest teleworks?

Subscribe Now