question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NPE during compile

See original GitHub issue

I have a new Scala module as part of a multi-module project. When attempting to compile with the new module, I get the following error:

$ mvn -T C1 -e clean package
...
[ERROR] Failed to execute goal net.alchim31.maven:scala-maven-plugin:3.3.1:compile (default) on project batch-spark: Execution default of goal net.alchim31.maven:scala-maven-plugin:3.3.1:compile failed.: NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal net.alchim31.maven:scala-maven-plugin:3.3.1:compile (default) on project batch-spark: Execution default of goal net.alchim31.maven:scala-maven-plugin:3.3.1:compile failed.
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
        at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call(MultiThreadedBuilder.java:200)
        at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call(MultiThreadedBuilder.java:196)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default of goal net.alchim31.maven:scala-maven-plugin:3.3.1:compile failed.
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:145)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
        ... 11 more
Caused by: java.lang.NullPointerException
        at scala_maven.FileUtils.pathOf(FileUtils.java:12)
        at scala_maven.ScalaMojoSupport.addCompilerToClasspath(ScalaMojoSupport.java:559)
        at scala_maven.ScalaMojoSupport.getToolClasspath(ScalaMojoSupport.java:825)
        at scala_maven.ScalaMojoSupport.getEmptyScalaCommand(ScalaMojoSupport.java:797)
        at scala_maven.ScalaMojoSupport.getScalaCommand(ScalaMojoSupport.java:753)
        at scala_maven.ScalaMojoSupport.getScalaCommand(ScalaMojoSupport.java:732)
        at scala_maven.ScalaCompilerSupport.compile(ScalaCompilerSupport.java:153)
        at scala_maven.ScalaCompilerSupport.doExecute(ScalaCompilerSupport.java:99)
        at scala_maven.ScalaMojoSupport.execute(ScalaMojoSupport.java:584)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
        ... 12 more
[ERROR] 
[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/PluginExecutionException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :batch-spark

The batch-spark submodule’s pom.xml contains the plugin:

        <sourceDirectory>src/main/scala</sourceDirectory>

        <plugins>
            <plugin>
                <groupId>net.alchim31.maven</groupId>
                <artifactId>scala-maven-plugin</artifactId>
                <version>3.3.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <scalaVersion>${scala.version}</scalaVersion>
                </configuration>
            </plugin>
        </plugins>
    </build>

Any recommendations on how to fix this?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
andreakcommented, Jan 30, 2018

Jep, removing <recompileMode>incremental</recompileMode> fixed it. Any news about if this will be fixed?

0reactions
davidBcommented, Feb 14, 2018

incremental support for java 9, will not be done.

The new zinc compiler will not be integrated in this plugin (until PR) And maybe to avoid this kind of issue in future version, the incremetal compiler option will be removed (or disabled for scala version > 2.12 or java version > 8)

You can take a look at https://github.com/random-maven/scalor-maven-plugin (works with zinc 1.x)

Read more comments on GitHub >

github_iconTop Results From Across the Web

[BUG] NPE during compiling when using Java 11 and ... - GitHub
I use Java 11 (tried with last versions of Oracle JDK and Zulu), Lombok 1.18.8 and maven-compiler-plugin 3.8.1. When I'm trying to compile...
Read more >
Java - best way to detect NPE at compile time when not ...
Java - best way to detect NPE at compile time when not allowed to use @NotNull or @Nullable annotations · Use Optional<T> in...
Read more >
Compile Time Checking for NullPointerException — oracle-tech
If all you need is to detect potential NPE prior to runtime testing, then compiler checks are not really necessary. There are plenty...
Read more >
Handling Java NullPointerException and Best Practices
Java NullPointerException (NPE) is an unchecked exception and extends RuntimeException . NullPointerException doesn't force us to use a ...
Read more >
Why null pointer exception is not compile time exception?
A NullPointerException (commonly referred to as an NPE ) is almost always the fault of a programmer writing bad code. It usually indicates...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found