Search code examples
mavengithub-actionsmaven-plugin

`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.

Solution

  • 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)