2

I've been trying to build an app but when I run maven, I catch this exception:

java.lang.ClassNotFoundException: org.apache.maven.plugin.surefire.SurefireReportParameters

I installed the maven-plugin manually, but the issue still continues. Any suggestion will be appreciated.

rtruszk
  • 3,902
  • 13
  • 36
  • 53
Raphael Milani
  • 151
  • 2
  • 14
  • 2
    Please share your pom.xml – bhdrkn Apr 20 '15 at 18:48
  • Also, see if you are using a JDK not a JRE, see it here for eclipse: http://stackoverflow.com/a/21099229/460557 – Jorge Campos Apr 21 '15 at 03:07
  • 1
    Hi @JorgeCampos: I am using JDK and I can´t share my POM because it´s of private Bank – Raphael Milani Apr 22 '15 at 14:05
  • This error is on eclipse or in the command line? Forget to ask before! – Jorge Campos Apr 23 '15 at 00:59
  • Hi @JorgeCampos this issue happens in both – Raphael Milani Apr 23 '15 at 20:36
  • Go to your repository on this path `repository\org\apache\maven\plugins\maven-surefire-plugin` see if there is a version of the plugin and if so see if there is a jar named `maven-surefire-plugin-x.xx.jar` – Jorge Campos Apr 24 '15 at 23:47
  • Hi @JorgeCampos on my repository there are many versions of maven-surefire-plugin.jar, but now occurs other exception: Caused by: java.lang.ClassNotFoundException: org.apache.maven.wagon.providers.http.HttpWagon – Raphael Milani Apr 27 '15 at 13:45
  • Most probably you have a configuration problem then. Check if you have set the maven enviroment `M2_HOME`, check also if your console is pointing to the proper JDK not JRE (I know I said it before, double check it with just calling `javac -version`), another possible problem is the jar on your current repository is corrupted so, go to your maven repository e.g. `c:\maven\repository` and rename it to `c:\maven\repository_` and run mvn install again it will redownload every jar, so it take some time to finish... – Jorge Campos Apr 27 '15 at 14:03
  • Hi @JorgeCampos I am going to try that, but my problem is: Failed to read artifact descriptor for org.codehaus.plexus:plexus-archiver:jar:2.6.3: Could not transfer artifact org.codehaus.plexus:plexus-archiver:pom:2.6.3 from/to R2DS-Group (https://dsnexus.uk.hibm.hsbc:8082/nexus/content/groups/R2DS-Group/): No connector available to access repository R2DS-Group (https://dsnexus.uk.hibm.hsbc:8082/nexus/content/groups/R2DS-Group/) of type default using the available factories WagonRepositoryConnectorFactory – Raphael Milani Apr 27 '15 at 14:09
  • Hi @JorgeCampos your suggestion worked! I "redownloaded" the whole internet. – Raphael Milani Apr 27 '15 at 17:25
  • hahahahaha good to know that I could Help. May I add this info as an answer? – Jorge Campos Apr 27 '15 at 18:20
  • Hi @JorgeCampos of course. Feel free! – Raphael Milani Apr 27 '15 at 18:49

2 Answers2

1

There are a few things that you should check about this problem.

I will enumarate then here so you could check.

  1. Check if you defined the JDK instead of the JRE on your path enviroment variables. Maven does not work properly only with the JRE. To check that go to your console and se if the javac -version command works.
  2. Check if you have the M2_HOME variable defined on your enviroment variables with the path where you installed maven.
  3. Since you are having a ClassNotFoundException on the SurefireReportParameters class check if the correspondent jar is on your local repository. It normally is on maven_path\repository\org\apache\maven\plugins\maven-surefire-plugin there it should have folder with versions and inside it a JAR file with the name: maven-surefire-plugin-x.xx.jar.
  4. Sometimes it happens that JAR files get corrupted from outside events of the O.S. or the IDE leading to the ClassNotFoundException as it would be very difficult to find all corrupted JARs I usually recomend to redownload the entiry repository again. Note that depending on the size of your project and number of dependencies you have on it this operation will take some time to complete. In order to do that you go to your repository folder (e.g. c:\maven\repository) and rename it (just the repository folder e.g. c:\maven\repository_) or delete it (just repository folder) then go to your project and run mvn install

One of this options should solve your problem. And as we discussed on the comments we already know which one it was. ;)

Jorge Campos
  • 22,647
  • 7
  • 56
  • 87
  • seems to be an unresolved (at this moment) bug: [SUREFIRE-1534](https://issues.apache.org/jira/browse/SUREFIRE-1534) – Adrian Nov 03 '18 at 22:53
  • 1
    blow away the maven-sunfire-plugin and maven-jar-plugin maven (.m2) directory worked for me – Jeryl Cook Jan 20 '21 at 15:32
  • 1
    @JerylCook Yeah, sometimes targeting only what seems to be the offending ones is also better than deleting everything :) – Jorge Campos Jan 20 '21 at 17:49
0

There are solutions posted for a similar question, but in the context of the Spring Framework.

Spring Boot fails to run maven-surefire-plugin ClassNotFoundException org.apache.maven.surefire.booter.ForkedBooter

One answer is to use version 3.0.0-M1 of the maven-surefire-plugin.

nichole
  • 121
  • 1
  • 6