Quarkus: NullPointerException in UnixPath.normalizeAndCheck()

Created on 5 Oct 2020  路  9Comments  路  Source: quarkusio/quarkus

Zulip thread: https://quarkusio.zulipchat.com/#narrow/stream/187030-users/topic/mvn.20quarkus.3Adev.20NPE

[INFO] --- quarkus-maven-plugin:1.7.0.Final:dev (default-cli) @ optaplanner-quarkus-school-timetabling-quickstart ---
Listening for transport dt_socket at address: 5005
Exception in thread "main" java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.NullPointerException
        at io.quarkus.deployment.dev.DevModeMain.start(DevModeMain.java:150)
        at io.quarkus.deployment.dev.DevModeMain.main(DevModeMain.java:63)
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.NullPointerException
        at io.quarkus.bootstrap.app.CuratedApplication.runInCl(CuratedApplication.java:135)
        at io.quarkus.bootstrap.app.CuratedApplication.runInAugmentClassLoader(CuratedApplication.java:85)
        at io.quarkus.deployment.dev.DevModeMain.start(DevModeMain.java:144)
        ... 1 more
Caused by: java.lang.RuntimeException: java.lang.NullPointerException
        at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:374)
        at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:51)
        at io.quarkus.bootstrap.app.CuratedApplication.runInCl(CuratedApplication.java:132)
        ... 3 more
Caused by: java.lang.NullPointerException
        at java.base/sun.nio.fs.UnixPath.normalizeAndCheck(UnixPath.java:75)
        at java.base/sun.nio.fs.UnixPath.<init>(UnixPath.java:69)
        at java.base/sun.nio.fs.UnixFileSystem.getPath(UnixFileSystem.java:279)
        at java.base/java.nio.file.Path.of(Path.java:147)
        at java.base/java.nio.file.Paths.get(Paths.java:69)
        at io.quarkus.deployment.dev.RuntimeUpdatesProcessor.checkForFileChange(RuntimeUpdatesProcessor.java:396)
        at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:346)
        ... 5 more

To reproduce

git clone [email protected]:kiegroup/optaplanner.git
cd optaplanner
git checkout 7.43.1.Final
cd optaplanner-quickstarts/quarkus-school-timetabling-quickstart
// Adjust pom.xml to use quarkus 1.8.1.Final
mvn clean compile quarkus:dev
aredevmode aredevtools kinbug

All 9 comments

The whole optaplanner projects needs to be compiled first.

The Q dev mode counts on the project target/ directories being present. In this case it tried to locate resourcesOutputPath for optaplanner-core, which would be optaplanner/optaplanner-core/target/classes/. The NPE was caused by the fact that this directory didn't exist.

However, even after compiling whole project tree, it still doesn't start because of some class loading issues...

@ge0ffrey It looks like a depenency resolution problem, some of the dependencies are idenfitied as local modules (e.g. optaplanner-core) which is obviously wrong because the quickstart pom.xml has not parent. The -DnoDeps system property solves the problem: mvn quarkus:dev -DnoDeps.

CC @aloubyansky

Thanks for the workaround @mkouba!

@TomasHofman The ClassLoader issues are unrelated to this issue (although this issue made it a hell to work on the CL one). Ignore the ClassLoader exception. That branch is just the easiest to reproduce.

Here is what happens and how to make it work.
First of all, Quarkus dev mode does not support live reloading of extensions. Which while you do have in your workspace, the extension artifacts themselves are added to the classpath as JARs, so not hot re-loadable. Which is totally fine but the issue is that there is also optaplanner/optaplanner-core which is a dependency of the extension, is discovered as a local project and is added as a hot re-loadable dependency. And this is what messes it all up.

The reason the extension artifacts aren't discovered by the Quarkus bootstrap is because the extension project is not added as a module of the parent project. If you e.g. do this
````
diff --git a/pom.xml b/pom.xml
index 9d9b6b7c1..d3e3ea998 100644
--- a/pom.xml
+++ b/pom.xml
@@ -71,6 +71,7 @@
optaplanner-benchmark
optaplanner-test
optaplanner-integration

BTW, I also noticed you were missing
````
diff --git a/optaplanner-quickstarts/pom.xml b/optaplanner-quickstarts/pom.xml
index e2f100e32..8d0707c0d 100644
--- a/optaplanner-quickstarts/pom.xml
+++ b/optaplanner-quickstarts/pom.xml
@@ -24,6 +24,7 @@


spring-boot-school-timetabling

  • quarkus-school-timetabling

    ````
    But this one does not have any effect on the reported issue.

About the last question, missing quickstart: that's because it's in a seperate profile in 7.x because it's not productized. On master (8.x) that's all ironed out and it nicely part of it in the repo optaplanner-quickstarts.

For clarity: @aloubyansky diagnozed and fixed another issue (a LinkageError) that was also occuring on that branch. The NPE on UnixPath.normalizeAndCheck is unrelated and hard to reproduce. But George and Guihaume have seen it too (see linked thread). I don't see it any more currently (yet my quarkus version hasn't really changed IIRC).

The NPE is not difficult to reproduce actually. If you run mvn clean on the main project and then try launching the dev mode you'll see the NPE. I'll open a PR with the fix shortly.

ah, and perhaps you should remove the optaplanner artifacts from the local repo.

Was this page helpful?
0 / 5 - 0 ratings