Uploaded image for project: 'Maven Surefire'
  1. Maven Surefire
  2. SUREFIRE-1837

NullPointerException at AbstractSurefireMojo$ClasspathCache.setCachedClasspath

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 3.0.0-M5
    • Fix Version/s: None
    • Component/s: Maven Surefire Plugin
    • Labels:
      None
    • Environment:

      Description

      While migrating a rather old and big project from Java 8 to Java 11 the following exception happens occasionally (once in 3-4 builds):

      [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M5:test (default-test) on project my_project: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M5:test failed.: NullPointerException -> [Help 1]
      org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M5:test (default-test) on project cachereloader-validation: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M5:test failed.
       at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
      at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
      at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
      at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
      at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:190)
      at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:186)
      at java.util.concurrent.FutureTask.run (FutureTask.java:264)
      at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:515)
      at java.util.concurrent.FutureTask.run (FutureTask.java:264)
      at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1128)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:628)
      at java.lang.Thread.run (Thread.java:834)
      Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M5:test failed.
       at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:148)
      at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
      at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
      at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
      at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
      at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:190)
      at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:186)
      at java.util.concurrent.FutureTask.run (FutureTask.java:264)
      at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:515)
      at java.util.concurrent.FutureTask.run (FutureTask.java:264)
      at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1128)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:628)
      at java.lang.Thread.run (Thread.java:834)
      Caused by: java.lang.NullPointerException
      at org.apache.maven.plugin.surefire.AbstractSurefireMojo$ClasspathCache.setCachedClasspath (AbstractSurefireMojo.java:4121)
      at org.apache.maven.plugin.surefire.AbstractSurefireMojo$ClasspathCache.access$200 (AbstractSurefireMojo.java:4102)
      at org.apache.maven.plugin.surefire.AbstractSurefireMojo.newStartupConfigWithClasspath (AbstractSurefireMojo.java:1913)
      at org.apache.maven.plugin.surefire.AbstractSurefireMojo.createStartupConfiguration (AbstractSurefireMojo.java:1894)
      at org.apache.maven.plugin.surefire.AbstractSurefireMojo.createForkStarter (AbstractSurefireMojo.java:2374)
      at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider (AbstractSurefireMojo.java:1310)
      at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked (AbstractSurefireMojo.java:1159)
      at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute (AbstractSurefireMojo.java:932)
      at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
      at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
      at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
      at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
      at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
      at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:190)
      at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:186)
      at java.util.concurrent.FutureTask.run (FutureTask.java:264)
      at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:515)
      at java.util.concurrent.FutureTask.run (FutureTask.java:264)
      at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1128)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:628)
      at java.lang.Thread.run (Thread.java:834)

      With exactly the same setup but using Java 8 this exception doesn't occur.
      The tests run on Jenkins ver. 2.204.6 like this:

       realtimeJUnit('**/target/surefire-reports/*.xml') {
           sh "mvn test -e -T 1C"
       }
      
      mvn --version
      Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
      Maven home: /opt/apache-maven-3.6.3
      Java version: 11.0.8, vendor: Amazon.com Inc., runtime: /usr/lib/jvm/java-11-amazon-corretto
      

      Also, with the plugin version 2.22.2 there is no exception but also occasionally some random tests fail with

      java.lang.NoClassDefFoundError: 
      ....
      Caused by: java.lang.ClassNotFoundException: 
      

      even thought classes are located right next to each other (sometimes it even fails to find inner static class)

      Plugin configuration

      <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>${surefire.version}</version>
          <configuration>
              <argLine>@{jacoco.agent.argLine} -Xmx512m -Xms256m ${custom.test.argLine}</argLine>
              <includes>
                  <include>**/*Test.java</include>
                  <include>**/*Specification.java</include>
              </includes>
              <excludes>
                  <exclude>**/*IntegrationTest.java</exclude>
              </excludes>
              <forkCount>1</forkCount>
              <forkedProcessTimeoutInSeconds>${test.timeout}</forkedProcessTimeoutInSeconds>
              <runOrder>random</runOrder>
              <reuseForks>true</reuseForks>
              <rerunFailingTestsCount>1</rerunFailingTestsCount>
              <testFailureIgnore>true</testFailureIgnore>
          </configuration>
      </plugin>
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              Enigo Ruslan Sibgatullin
            • Votes:
              2 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated: