-
-
Notifications
You must be signed in to change notification settings - Fork 566
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Javalin with JPMS and ServiceLoader results in NoClassDefFoundError: kotlin/NoWhenBranchMatchedException #1624
Comments
@baumgarb |
You could check out https://github.com/vihangpatil/kotlin-modules ? |
@tipsy haven't mixed in any Kotlin based libraries or projects into my Java 9+ Gradle and JPMS projects yet. That's a first and probably you're right. I'll have a look at https://github.com/vihangpatil/kotlin-modules and let's see if I can figure out something. Thank you very much either way :-) |
Kotlin stdlib supports modules since 1.4+, but Javalin does not export dedicated module-info with library, so in theory it's should work in unnamed module. Because this class cannot be found, you have to find a way to link kotlin stdlib in your project. |
Issue's solved now, I've pushed a new branch showing how to make it work, see main-solved. If you don't want to bother looking at the latest commit 1f80fc7 of this branch then here's the solution: simply add this line to the
The root cause seems to be that Javalin is not modularized yet. If you look closer into the module resolution (pass Thanks a lot to @rraumberger who helped me getting to the bottom of this and came up with the solution, but is too shy to post it here :-P |
Do you happen to know what we can do in Javalin to fix this?
He sounds like a great guy!
Might make an interesting tutorial for https://javalin.io/tutorials, if you're interested in writing one? |
Not off top of my head, I will take a look, maybe there's a quick win we can achieve other than fully introducing modules in the repo.
You seem to have a great gut feeling, indeed he is 👍 :-D
Oh it would be my pleasure, I'd be honored to contribute and I'll definitely do so, thx for offering :-) |
@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 javalin/website#136. |
I'll also close this now :) |
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.
(✗) Clone main branch and follow README.md to step 3 and you well end up with the exception:
Additional context
n/a
The text was updated successfully, but these errors were encountered: