Javalin with JPMS and ServiceLoader results in NoClassDefFoundError: kotlin/NoWhenBranchMatchedException
See original GitHub issueActual behavior (the bug) Running Javalin with JPMS and ServiceLoader leads to the a NoClassDefFoundError. If I run the very same application not as a module and without the service loader everything works just fine.
Expected behavior I’m expecting Javalin to work with JPMS and ServiceLoader the same way it does for a console application without Javalin. If you run the console application in the same project everything works out just fine.
To Reproduce
-
(✓) Clone no-jpms-and-serviceloader branch and you’ll see everything works fine.
-
(✓) Run console app in very same project and you’ll see everything works fine as well with ServiceLoader and JPMS in place.
.\gradlew.bat :client:run
-
(✗) Clone main branch and follow README.md to step 3 and you well end up with the exception:
> Task :api:run FAILED [main] INFO org.example.api.WebAPI - Hello World from WebAPI, yay :-) Exception in thread "main" java.lang.NoClassDefFoundError: kotlin/NoWhenBranchMatchedException at io.javalin@4.6.4/io.javalin.core.JavalinConfig$Inner.<init>(JavalinConfig.java:77) at io.javalin@4.6.4/io.javalin.core.JavalinConfig.<init>(JavalinConfig.java:67) at io.javalin@4.6.4/io.javalin.Javalin.<init>(Javalin.java:54) at io.javalin@4.6.4/io.javalin.Javalin.create(Javalin.java:91) at io.javalin@4.6.4/io.javalin.Javalin.create(Javalin.java:78) at org.example.api/org.example.api.WebAPI.main(WebAPI.java:24) Caused by: java.lang.ClassNotFoundException: kotlin.NoWhenBranchMatchedException at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) ... 6 more FAILURE: Build failed with an exception.
Additional context n/a
Issue Analytics
- State:
- Created a year ago
- Comments:10 (6 by maintainers)
Top GitHub Comments
@tipsy FYI, I’ve created a PR for adding a tutorial on javalin.io on how to setup a bare bone Gradle project with Javalin & JPMS which also makes use of the new ServiceLoader infrastructure. See PR https://github.com/javalin/javalin.github.io/pull/136.
@baumgarb that’s a really well written tutorial @baumgarb, thank you !