Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

`A required class was missing while executing` maven plugin with GitHub action

Recently my GitHub actions failed on specific maven goal complaining that a required class (from plexus-utils) was missing.

Everything worked well until now and still works well locally.

(⚠ In my case this affects, impsort-maven-plugin but this can affect other maven-plugin, see answer to better understand)

Here is the complete log for me ❌ :

Error:  

Failed to execute goal net.revelc.code:impsort-maven-plugin:1.6.2:check (default-cli) on project leshan-core: 
Execution default-cli of goal net.revelc.code:impsort-maven-plugin:1.6.2:check failed:
A required class was missing while executing net.revelc.code:impsort-maven-plugin:1.6.2:check:
org/codehaus/plexus/util/DirectoryScanner

Error:  -----------------------------------------------------
Error:  realm =    plugin>net.revelc.code:impsort-maven-plugin:1.6.2
Error:  strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
Error:  urls[0] = file:/home/runner/.m2/repository/net/revelc/code/impsort-maven-plugin/1.6.2/impsort-maven-plugin-1.6.2.jar
Error:  urls[1] = file:/home/runner/.m2/repository/com/github/javaparser/javaparser-core/3.22.1/javaparser-core-3.22.1.jar
Error:  urls[2] = file:/home/runner/.m2/repository/com/google/guava/guava/30.1.1-jre/guava-30.1.1-jre.jar
Error:  urls[3] = file:/home/runner/.m2/repository/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar
Error:  urls[4] = file:/home/runner/.m2/repository/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar
Error:  urls[5] = file:/home/runner/.m2/repository/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar
Error:  urls[6] = file:/home/runner/.m2/repository/org/checkerframework/checker-qual/3.8.0/checker-qual-3.8.0.jar
Error:  urls[7] = file:/home/runner/.m2/repository/com/google/errorprone/error_prone_annotations/2.5.1/error_prone_annotations-2.5.1.jar
Error:  urls[8] = file:/home/runner/.m2/repository/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3.jar
Error:  Number of foreign imports: 1
Error:  import: Entry[import  from realm ClassRealm[project>org.eclipse.leshan:leshan-core:2.0.0-SNAPSHOT, parent: ClassRealm[maven.api, parent: null]]]
Error:  
Error:  -----------------------------------------------------: org.codehaus.plexus.util.DirectoryScanner
Error:  -> [Help 1]
Error:  
Error:  To see the full stack trace of the errors, re-run Maven with the -e switch.
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 read the following articles:
Error:  [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException
Error: Process completed with exit code 1.
like image 224
sbernard Avatar asked Mar 25 '26 10:03

sbernard


2 Answers

It seems this happens because :

  1. Since recently default GitHub image runner are now using maven 3.9.0 (see runner-images#7216)
  2. Maven 3.9.0 remove backward compatibility dependency to plexus-utils (see maven-3.9.0/release-notes)
  3. impsort-maven-plugin does NOT declares COMPILE dependency on plexus-utils (see impsort-maven-plugin#64)

This problem could be faced with other maven-plugin.
If you face it, you can do 👇 waiting plugin maintainer fix this :

<plugin>
  <groupId>net.revelc.code</groupId>
  <artifactId>impsort-maven-plugin</artifactId>
  <version>1.6.2</version>
  <dependencies>
    <dependency>
      <groupId>org.codehaus.plexus</groupId>
      <artifactId>plexus-utils</artifactId>
      <version>3.5.1</version>
    </dependency>
  </dependencies>
</plugin>

(More details at runner-images#7216-issuecomment-1455954873)

like image 78
sbernard Avatar answered Mar 28 '26 00:03

sbernard


Alternatively – and to be independent from the runner's Maven version – you can use a Maven Wrapper:

The Maven Wrapper is an easy way to ensure a user of your Maven build has everything necessary to run your Maven build.

Why might this be necessary? Maven to date has been very stable for users, is available on most systems or is easy to procure: but with many of the recent changes in Maven it will be easier for users to have a fully encapsulated build setup provided by the project. With the Maven Wrapper, this is very easy to do and it's a great idea and initial implementation borrowed from Gradle.

To e.g. downgrade to Maven 3.8.8:

mvn wrapper:wrapper -Dmaven=3.8.8

Afterwards, replace "mvn" with "./mvnw" in your workflows.

like image 36
beatngu13 Avatar answered Mar 27 '26 22:03

beatngu13



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!