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 fails to start on latest Loom Early Access Build

See original GitHub issue

Actual 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:

https://download.java.net/java/early_access/loom/docs/api/java.base/java/util/concurrent/Executors.html

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
tipsycommented, Nov 28, 2021

@pkkummermo That seems like a bit too much effort for a preview feature, I’m happy with the merged PR.

0reactions
pkkummermocommented, Nov 18, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

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