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.

Javalin with JPMS and ServiceLoader results in NoClassDefFoundError: kotlin/NoWhenBranchMatchedException

See original GitHub 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 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:closed
  • Created a year ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
baumgarbcommented, Aug 8, 2022

@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.

1reaction
tipsycommented, Aug 9, 2022

@baumgarb that’s a really well written tutorial @baumgarb, thank you !

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - Javalin with JPMS and ServiceLoader results in ...
Running Javalin with JPMS and ServiceLoader leads to a NoClassDefFoundError: kotlin/NoWhenBranchMatchedException .
Read more >
Javalin with Java Platform Module System (JPMS) and Gradle
What You Will LearnIn this tutorial we will learn how to create a simple RESTful API based on Javalin and the Java Platform...
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