Javalin fails to start on latest Loom Early Access Build
See original GitHub issueActual behavior (the bug)
Javalin fails to start when running on the latest Project Loom Early Access build.
Exception in thread "main" java.lang.NoSuchMethodException: java.util.concurrent.Executors.newVirtualThreadExecutor()
at java.base/java.lang.Class.getMethod(Class.java:2259)
at io.javalin.core.LoomUtil.getExecutorService(LoomUtil.kt:22)
at io.javalin.jetty.LoomThreadPool.<init>(JettyUtil.kt:89)
at io.javalin.jetty.JettyUtil.defaultThreadPool(JettyUtil.kt:28)
at io.javalin.jetty.JettyUtil.getOrDefault(JettyUtil.kt:20)
at io.javalin.jetty.JettyServer.server(JettyServer.kt:34)
at io.javalin.Javalin.start(Javalin.java:179)
at io.javalin.Javalin.start(Javalin.java:147)
at Main.main(Main.java:6)
Expected behavior
Javalin starts normally.
To Reproduce
Run Javalin with the latest preview build 18-loom+5-274
http://jdk.java.net/loom/
Additional context
The getExecutorService
function is referencing the old method name for getting an ExecutorService
that utilizes virtual threads.
fun getExecutorService(): ExecutorService {
if (!loomAvailable) {
throw IllegalStateException("Your Java version (${System.getProperty("java.version")}) doesn't support Loom")
}
return Executors::class.java.getMethod("newVirtualThreadExecutor").invoke(Executors::class.java) as ExecutorService
}
It should be looking for newVirtualThreadPerTaskExecutor
according to the latest docs:
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Javalin fails to start on latest Loom Early Access Build #1437
Actual behavior (the bug) Javalin fails to start when running on the latest Project Loom Early Access build. Exception in thread "main" ...
Read more >Documentation - A lightweight Java and Kotlin web framework
Javalin - A lightweight Java and Kotlin web framework. Create REST APIs in Java or Kotlin easily.
Read more >Show HN: I finished v5 of a JVM framework I've ... - Hacker News
Calling a constructor is DI. 'new' is the only DI framework required. Benefits: Unbelievably fast startup time. No magic.
Read more >Project Loom early access IDE - Stack Overflow
Note however that IDE will most likely not recognize any new syntax and you will be better to use a build tool such...
Read more >Loom Early-Access Builds - Java (JDK)
Project Loom. Please use the OpenJDK JDK 20 Early-Access Builds page for downloads. Notes. JEP 425: Virtual Threads (Preview) was integrated in JDK...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@pkkummermo That seems like a bit too much effort for a preview feature, I’m happy with the merged PR.
A quick fix during the preview timeline, would be to check on multiple methods and just check if one of them exists. If there’s no match, throw an Exception with a link to either this issue or the Javalin repo 😃
Edit: We could even toss in a
.warn
when you’re using an old preview build.