Javalin fails on Java 19 without --enable-preview
See original GitHub issueActual behavior (the bug)
I ran brew upgrade
which gave me Java 19. When I booted up my Javalin app I saw this exception:
20220928 17:09:36.260 [main] INFO / io.javalin.Javalin - Starting Javalin ...
20220928 17:09:36.271 [main] INFO / io.javalin.Javalin - You are running Javalin 4.6.4 (released July 8, 2022).
20220928 17:09:36.301 [main] INFO / io.javalin.Javalin - Loom is available, using Virtual ThreadPool... Neat!
20220928 17:09:36.303 [main] ERROR / io.javalin.Javalin - Failed to start Javalin
20220928 17:09:36.305 [main] INFO / io.javalin.Javalin - Loom is available, using Virtual ThreadPool... Neat!
Exception in thread "main" java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:119)
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
at io.javalin.core.LoomUtil.getExecutorService(LoomUtil.kt:22)
at io.javalin.jetty.LoomThreadPool.<init>(JettyUtil.kt:90)
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:180)
at io.javalin.Javalin.start(Javalin.java:148)
[...]
Caused by: java.lang.UnsupportedOperationException: Preview Features not enabled, need to run with --enable-preview
at java.base/jdk.internal.misc.PreviewFeatures.ensureEnabled(PreviewFeatures.java:49)
at java.base/java.lang.Thread.ofVirtual(Thread.java:833)
at java.base/java.util.concurrent.Executors.newVirtualThreadPerTaskExecutor(Executors.java:274)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
... 10 more
Expected behavior Javalin should work (without virtual threadpools) on Java 19 without loom enabled.
To Reproduce
Run Javalin with Java 19 and without the --enable-preview
flag.
Additional context
To fix it, in IntelliJ I edited my run configuration, and added --enable-preview
to the VM Options section.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Javalin fails on Java 19 without --enable-preview - PullAnswer
To Reproduce Run Javalin with Java 19 and without the --enable-preview flag. Additional context To fix it, in IntelliJ I edited my run...
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 >Preview features are not enabled. Try running with - GitHub
1:generate phase? java.lang.IllegalStateException: Failed to introspect Class [MediaPlaylistController] from ClassLoader [jdk.internal.loader.
Read more >Show HN: I finished v5 of a JVM framework I've ... - Hacker News
I ended up using Javalin with Kotlin and SQLite to build my wedding ... In no other language is 'calling a constructor' considered...
Read more >How to remove --enable-preview in Java 16? - Stack Overflow
This is not a compile-time error. You get it when trying to run a .java class compiled with --enable-preview parameter, directly.
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
Now that was fast! Thanks so much!
4.6.5
should be out now 😃