Javalin with JPMS and ServiceLoader results in NoClassDefFoundError: kotlin/NoWhenBranchMatchedException
envgap__javalin__javalin-1624
Original GitHub issue ↗Opened 2022-07-26
01 / FAILURE SIGNATURE
As reported upstream
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.
Not a benchmark task.
- No curated issue-specific recipe or verified environment fix is available.
02 / ENVIRONMENT RECIPE
- Base commit
Not freshly verified- Manifest
pom.xml- Reproduce
Awaiting issue-specific recipe- Run under trace
Awaiting a meaningful runtime command
03 / ORIGINAL ISSUE TEXT
javalin/javalin #1624 · read the original issue
**Actual 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](https://github.com/baumgarb/javalin-with-jpms/tree/no-jpms-and-serviceloader) 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](https://github.com/baumgarb/javalin-with-jpms/tree/main) 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
04 / LABELS
Labels from the report text only; not yet run
No supported category has been assigned.
Label rules and the text that matched
[]
Issue-specific recipe and runtime smoke command require review against the complete issue and repository.
Legacy reproduction is generic install-only; match the actual issue failure before admission.