Hey, unfortunatley the documentation site is not working for me so I am trying to figure out a simple hello world for Java + Vaadin 24 + Gradle as I am not a fan of spring boot and maven.
What dependencies do I need
Any Gradle Plugins that are required?
How does the minimal Application Main look like (including a simple view with a text box and maybe a button)
Can i also hot-reload? I used vaadin a few years ago with spring boot and remember that it was working there
Oh and is there a discord Server? I hate using a forum, registering for every single application or library that I use and I would become confused. Thats why I prefer to use discord, all in one place and it notifies me on updates.
with Gradle 8.14.3 it is going further. Now I have the issue that Java 23 is too “new” for jetty 11. Has someone got a working simple hello world with any new version such as newest gradle and newest java or is vaadin way behind official releases?
The problem here seems not to be Vaadin, which works fine with Java 25 and Jetty 12.
Doing a quick test, I’d say the issue is with the Gretty Gradle plugin. If you update it to the latest (4.1.10), Jetty starts but then it complains about “Unsupported class file major version 67”
|java.lang.IllegalArgumentException: Unsupported class file major version 67
| at org.objectweb.asm.ClassReader.<init>(ClassReader.java:200)
| at org.objectweb.asm.ClassReader.<init>(ClassReader.java:180)
| at org.objectweb.asm.ClassReader.<init>(ClassReader.java:166)
| at org.objectweb.asm.ClassReader.<init>(ClassReader.java:288)
| at org.eclipse.jetty.annotations.AnnotationParser.scanClass(AnnotationParser.java:896)
| at org.eclipse.jetty.annotations.AnnotationParser.parseDir(AnnotationParser.java:795)
| at org.eclipse.jetty.annotations.AnnotationParser.parse(AnnotationParser.java:730)
| at org.eclipse.jetty.annotations.AnnotationConfiguration$ParserTask.call(AnnotationConfiguration.java:159)
| at org.eclipse.jetty.annotations.AnnotationConfiguration$1.run(AnnotationConfiguration.java:540)
| at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:969)
| at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.doRunJob(QueuedThreadPool.java:1194)
| at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1149)
| at java.base/java.lang.Thread.run(Thread.java:1575)
Actually, Gradle 9 support has been added to Gretty in 4.1.10 (Gradle 9 support · Issue #322 · gretty-gradle-plugin/gretty · GitHub)
About Java 23, I don’t know if it is still an issue with Gretty providing a too old ASM version or Jetty itself depending on that older ASM.
Unfortunately, I cannot help further (not a Gradle expert).
However, if you switch from Jetty to Tomcat (servletContainer = 'tomcat10') the application starts fine.
Since the Conversation here is very delayed I am putting more questions in here, maybe you or someone else has a solution for that:
i have another issue: When i run in IntelliJ with appRun, it does not stop when i stop the application. It only stops when i press enter in the console there which is very inconvenient when I need to restart it
Is there a single entry? For example an application start event that I can use to initialize my db connections etc.
My Console is also full with this error, did i forgot something?
java.net.ConnectException: Operation timed out
at java.base/sun.nio.ch.Net.connect0(Native Method)
at java.base/sun.nio.ch.Net.connect(Net.java:589)
at java.base/sun.nio.ch.Net.connect(Net.java:578)
at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:583)
at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327)
at java.base/java.net.Socket.connect(Socket.java:751)
at java.base/java.net.Socket.connect(Socket.java:686)
at java.base/java.net.Socket.(Socket.java:555)
at java.base/java.net.Socket.(Socket.java:356)
at org.akhikhl.gretty.ServiceProtocol$Writer.write(ServiceProtocol.groovy:71)
at org.akhikhl.gretty.ServiceProtocol$Writer.writeMayFail(ServiceProtocol.groovy:83)
at org.akhikhl.gretty.ServiceProtocol$Writer$writeMayFail.call(Unknown Source)
at org.akhikhl.gretty.Runner.onServerStarted(Runner.groovy:139)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at org.codehaus.groovy.runtime.callsite.PlainObjectMetaMethodSite.doInvoke(PlainObjectMetaMethodSite.java:48)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:189)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:57)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:194)
at org.akhikhl.gretty.Runner.run(Runner.groovy:97)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at org.codehaus.groovy.runtime.callsite.PlainObjectMetaMethodSite.doInvoke(PlainObjectMetaMethodSite.java:48)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:189)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:69)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:130)
at org.akhikhl.gretty.Runner.main(Runner.groovy:35)
About the Copilot issue, it looks like there’s a dependency mismatch with the javaparser library; it looks like the application is using a version incompatible with Copilot.
java.lang.ExceptionInInitializerError: Exception java.lang.NoSuchFieldError: Class com.github.javaparser.ParserConfiguration$LanguageLevel does not have member field 'com.github.javaparser.ParserConfiguration$LanguageLevel JAVA_21' [in thread "main"]
com.vaadin.copilot.Copilot.<clinit>(Copilot.java:30)
com.vaadin.copilot.CopilotIndexHtmlLoader.serviceInit(CopilotIndexHtmlLoader.java:46)
com.vaadin.flow.server.VaadinService.lambda$init$0(VaadinService.java:283)
I cannot help with that since I have no experience running apps in the IDE with Gradle.
It depends on your application. You can use a ServletContextListener or a ServletContainerInitializer for example. About Vaadin itself, the hook could be a VaadinServiceInitListener
I have no idea about the last stack trace, but it looks like something related to the Gretty Gradle plugin.
I also have so many other issues that I do not have with a simple plain java Application. It feels like vaadin is mostly working in the Web UI but in the backend it throws so much exceptions and errors that I cant get through them. Is there a way to add vaadin as a very minimal dependency? In my current setup its running with jetty (tried tomcat, is not better), war for deployment and it has no main class, I have almost no control of the application.
I would like to add vaadin more as a dependency to have my main structure and application lifecycle and then it handles web requests in the background.
I’m not sure if I understand what’s problem.
If you are building a WAR that should run in a servlet container, you just need to add the com.vaadin:vaadin-core dependency (or com.vaadin:vaadin if you plan to use commercial components).
If you are not interested in the Vaadin dev tools (frontend hot reload, Copilot, …), just exclude com.vaadin:vaadin-dev from com.vaadin:vaadin-core).
If you want to create a JAR with an embedded servlet container but don’t want to use Spring Boot, there are several ways to do it, but you need to check the documentation of the selected container. Or you can take a look at the excellent Vaadin Boot project by @mavi1
Please correct me if I did not understand your question.
Edit: I forgot to mention that Quarkus is also a great alternative.