mcollovati / quarkus-hilla

A Quarkus extension to run Hilla applications on Quarkus.
Apache License 2.0
15 stars 0 forks source link

Trying to get Quarkus + Vaadin + Hilla working #1023

Closed edeandrea closed 3 weeks ago

edeandrea commented 3 weeks ago

Describe the bug This could totally be user error as I'm not really too familiar with Vaadin nor Hilla.

I'm attempting to create a Quarkus version of https://github.com/marcushellberg/java-ai-playground (see marcushellberg/java-ai-playground#21 - source code of what I'm trying to do is at https://github.com/edeandrea/java-ai-playground/tree/quarkus).

Everything builds, but when I try and load the app in the browser I'm getting

╰─ quarkus dev --clean -Dquarkus.profile=ollama                                                                                       
[INFO] Scanning for projects...
[INFO] 
[INFO] ----------------< org.vaadin.marcus:java-ai-playground >----------------
[INFO] Building java-ai-playground 1.0-SNAPSHOT
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- clean:3.2.0:clean (default-clean) @ java-ai-playground ---
[INFO] Deleting /Users/edeandre/workspaces/IntelliJ/java-ai-playground/target
[INFO] 
[INFO] --- quarkus:3.15.1:dev (default-cli) @ java-ai-playground ---
[INFO] Invoking vaadin:24.4.13:prepare-frontend (default) @ java-ai-playground
[INFO] Reflections took 714 ms to scan 422 urls, producing 14615 keys and 70061 values
[INFO] Reflections took 406 ms to scan 422 urls, producing 14615 keys and 70061 values
[INFO] Reflections took 404 ms to scan 422 urls, producing 14615 keys and 70061 values
[INFO] Reflections took 360 ms to scan 422 urls, producing 14615 keys and 70061 values
[INFO] Visited 106 classes. Took 74 ms.
[INFO] Copying frontend resources from jar files ...
[INFO] Visited 526 resources. Took 161 ms.
[INFO] Invoking resources:3.3.1:resources (default-resources) @ java-ai-playground
[INFO] Copying 4 resources from src/main/resources to target/classes
[INFO] Invoking quarkus:3.15.1:generate-code (default) @ java-ai-playground
[INFO] Invoking compiler:3.13.0:compile (default-compile) @ java-ai-playground
[INFO] Recompiling the module because of changed source code.
[INFO] Compiling 15 source files with javac [debug release 17] to target/classes
[INFO] /Users/edeandre/workspaces/IntelliJ/java-ai-playground/src/main/java/org/vaadin/marcus/langchain4j/LangChain4jConfig.java: /Users/edeandre/workspaces/IntelliJ/java-ai-playground/src/main/java/org/vaadin/marcus/langchain4j/LangChain4jConfig.java uses unchecked or unsafe operations.
[INFO] /Users/edeandre/workspaces/IntelliJ/java-ai-playground/src/main/java/org/vaadin/marcus/langchain4j/LangChain4jConfig.java: Recompile with -Xlint:unchecked for details.
[INFO] Invoking resources:3.3.1:testResources (default-testResources) @ java-ai-playground
[INFO] skip non existing resourceDirectory /Users/edeandre/workspaces/IntelliJ/java-ai-playground/src/test/resources
[INFO] Invoking quarkus:3.15.1:generate-code-tests (default) @ java-ai-playground
[INFO] Invoking compiler:3.13.0:testCompile (default-testCompile) @ java-ai-playground
[INFO] Recompiling the module because of changed dependency.
[INFO] Compiling 1 source file with javac [debug release 17] to target/test-classes
Listening for transport dt_socket at address: 5005
__  ____  __  _____   ___  __ ____  ______ 
 --/ __ \/ / / / _ | / _ \/ //_/ / / / __/ 
 -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \   
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/   
2024-10-31 09:33:18,843 WARN  [io.qua.config] (Quarkus Main Thread) Unrecognized configuration key "quarkus.langchain4j.ollama.embedding-model.model-name" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
2024-10-31 09:33:18,844 WARN  [io.qua.config] (Quarkus Main Thread) Unrecognized configuration key "quarkus.langchain4j.ollama.chat-model.model-name" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
2024-10-31 09:33:18,844 WARN  [io.qua.config] (Quarkus Main Thread) Unrecognized configuration key "quarkus.langchain4j.easy-rag.min-score" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
2024-10-31 09:33:18,844 WARN  [io.qua.config] (Quarkus Main Thread) Unrecognized configuration key "quarkus.resteasy.path" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
2024-10-31 09:33:19,366 INFO  [com.vaa.bas.dev.sta.DevModeStartupListener] (Quarkus Main Thread) Starting dev-mode updaters in /Users/edeandre/workspaces/IntelliJ/java-ai-playground folder.
2024-10-31 09:33:19,401 INFO  [com.vaa.flo.ser.fro.sca.FullDependenciesScanner] (Quarkus Main Thread) Visited 71 classes. Took 13 ms.
2024-10-31 09:33:19,508 INFO  [io.und.servlet] (Quarkus Main Thread) Initializing AtmosphereFramework
2024-10-31 09:33:19,521 INFO  [com.vaa.flo.ser.sta.ServletDeployer] (Quarkus Main Thread) Skipping automatic servlet registration because there is already a Vaadin servlet with the name com.vaadin.quarkus.QuarkusVaadinServlet
2024-10-31 09:33:19,541 INFO  [io.und.websockets] (Quarkus Main Thread) UT026005: Adding programmatic server endpoint class org.atmosphere.container.JSR356Endpoint for path /VAADIN/push
2024-10-31 09:33:19,542 INFO  [io.und.websockets] (Quarkus Main Thread) UT026005: Adding programmatic server endpoint class org.atmosphere.container.JSR356Endpoint for path /VAADIN/push/
2024-10-31 09:33:19,545 INFO  [com.vaa.flo.ser.fro.TaskUpdatePackages] (ForkJoinPool.commonPool-worker-8) Skipping `npm install` because the frontend packages are already installed in the folder '/Users/edeandre/workspaces/IntelliJ/java-ai-playground/node_modules' and the hash in the file '/Users/edeandre/workspaces/IntelliJ/java-ai-playground/node_modules/.vaadin/vaadin.json' is the same as in 'package.json'
2024-10-31 09:33:19,565 INFO  [io.und.websockets] (Quarkus Main Thread) UT026005: Adding programmatic server endpoint class org.atmosphere.container.JSR356Endpoint for path /HILLA/push
2024-10-31 09:33:19,565 INFO  [io.und.websockets] (Quarkus Main Thread) UT026005: Adding programmatic server endpoint class org.atmosphere.container.JSR356Endpoint for path /HILLA/push/
2024-10-31 09:33:19,565 INFO  [io.und.websockets] (Quarkus Main Thread) UT026005: Adding programmatic server endpoint class org.atmosphere.container.JSR356Endpoint for path /HILLA/push/{path0}
2024-10-31 09:33:19,565 INFO  [io.und.websockets] (Quarkus Main Thread) UT026005: Adding programmatic server endpoint class org.atmosphere.container.JSR356Endpoint for path /HILLA/push/{path0}/{path1}
2024-10-31 09:33:19,565 INFO  [io.und.websockets] (Quarkus Main Thread) UT026005: Adding programmatic server endpoint class org.atmosphere.container.JSR356Endpoint for path /HILLA/push/{path0}/{path1}/{path2}
2024-10-31 09:33:19,565 INFO  [io.und.websockets] (Quarkus Main Thread) UT026005: Adding programmatic server endpoint class org.atmosphere.container.JSR356Endpoint for path /HILLA/push/{path0}/{path1}/{path2}/{path3}
2024-10-31 09:33:19,565 INFO  [io.und.websockets] (Quarkus Main Thread) UT026005: Adding programmatic server endpoint class org.atmosphere.container.JSR356Endpoint for path /HILLA/push/{path0}/{path1}/{path2}/{path3}/{path4}
2024-10-31 09:33:19,606 INFO  [com.vaa.flo.ser.DefaultDeploymentConfiguration] (Quarkus Main Thread) 
Vaadin is running in DEVELOPMENT mode - do not use for production deployments.
2024-10-31 09:33:19,614 INFO  [com.vaa.qua.QuarkusInstantiator] (Quarkus Main Thread) Can't find any @VaadinServiceScoped bean implementing 'I18NProvider'. Cannot use CDI beans for I18N, falling back to the default behavior.
2024-10-31 09:33:19,669 INFO  [io.und.websockets] (Quarkus Main Thread) UT026005: Adding programmatic server endpoint class com.vaadin.base.devserver.viteproxy.ViteWebsocketEndpoint for path /VAADIN/
2024-10-31 09:33:19,891 INFO  [io.qua.lan.eas.run.EasyRagRecorder] (Quarkus Main Thread) Reading embeddings from /Users/edeandre/workspaces/IntelliJ/java-ai-playground/easy-rag-embeddings.json
2024-10-31 09:33:19,935 INFO  [org.vaa.mar.ser.FlightService] (Quarkus Main Thread) Demo data initialized
2024-10-31 09:33:19,976 INFO  [io.quarkus] (Quarkus Main Thread) java-ai-playground 1.0-SNAPSHOT on JVM (powered by Quarkus 3.15.1) started in 3.340s. Listening on: http://localhost:8080
2024-10-31 09:33:19,976 INFO  [io.quarkus] (Quarkus Main Thread) Profile ollama activated. Live Coding activated.
2024-10-31 09:33:19,976 INFO  [io.quarkus] (Quarkus Main Thread) Installed features: [awt, cdi, hibernate-validator, langchain4j, langchain4j-easy-rag, langchain4j-ollama, langchain4j-openai, opentelemetry, poi, quarkus-hilla, qute, rest, rest-client, rest-client-jackson, rest-jackson, servlet, smallrye-context-propagation, vaadin-quarkus, vertx, websockets, websockets-client]
2024-10-31 09:33:25,331 INFO  [com.vaa.flo.ser.fro.TaskCopyFrontendFiles] (ForkJoinPool.commonPool-worker-8) Copying frontend resources from jar files ...
2024-10-31 09:33:25,392 INFO  [com.vaa.flo.ser.fro.TaskCopyFrontendFiles] (ForkJoinPool.commonPool-worker-8) Visited 21 resources. Took 61 ms.
2024-10-31 09:33:25,462 INFO  [com.vaa.bas.dev.AbstractDevServerRunner] (ForkJoinPool.commonPool-worker-8) Starting Vite

------------------ Starting Frontend compilation. ------------------
2024-10-31 09:33:26,308 INFO  [com.vaa.bas.dev.AbstractDevServerRunner] (ForkJoinPool.commonPool-worker-8) Running Vite to compile frontend resources. This may take a moment, please stand by...
2024-10-31 09:33:27,817 INFO  [com.vaa.bas.dev.DevServerOutputTracker] (dev-server-output) 
2024-10-31 09:33:27,818 INFO  [com.vaa.bas.dev.DevServerOutputTracker] (dev-server-output)   VITE v5.4.6  ready in 1464 ms

----------------- Frontend compiled successfully. -----------------

2024-10-31 09:33:27,818 INFO  [com.vaa.bas.dev.DevServerOutputTracker] (dev-server-output) 
2024-10-31 09:33:27,819 INFO  [com.vaa.bas.dev.DevServerOutputTracker] (dev-server-output)   ➜  Local:   http://127.0.0.1:51237/VAADIN/
2024-10-31 09:33:27,818 INFO  [com.vaa.bas.dev.AbstractDevServerRunner] (ForkJoinPool.commonPool-worker-8) Started Vite. Time: 2356ms
2024-10-31 09:33:29,893 INFO  [com.vaa.bas.dev.DevServerOutputTracker] (dev-server-output) 
2024-10-31 09:33:29,894 INFO  [com.vaa.bas.dev.DevServerOutputTracker] (dev-server-output) [TypeScript] Found 0 errors. Watching for file changes.
2024-10-31 09:34:34,989 ERROR [com.vaa.flo.ser.DefaultErrorHandler] (executor-thread-1) : java.lang.IllegalArgumentException: Unable to create an instance of 'com.vaadin.flow.server.auth.MenuAccessControl'. Make sure the class has a public no-arg constructor.
        at com.vaadin.flow.internal.ReflectTools.createProxyInstance(ReflectTools.java:520)
        at com.vaadin.flow.internal.ReflectTools.createInstance(ReflectTools.java:452)
        at com.vaadin.flow.di.DefaultInstantiator.create(DefaultInstantiator.java:198)
        at com.vaadin.flow.di.DefaultInstantiator.getOrCreate(DefaultInstantiator.java:72)
        at com.vaadin.quarkus.QuarkusInstantiator.lambda$getOrCreate$2(QuarkusInstantiator.java:77)
        at com.vaadin.quarkus.BeanLookup.lookupOrElseGet(BeanLookup.java:94)
        at com.vaadin.quarkus.QuarkusInstantiator.getOrCreate(QuarkusInstantiator.java:76)
        at com.vaadin.flow.di.Instantiator.getMenuAccessControl(Instantiator.java:217)
        at com.vaadin.hilla.route.RouteUnifyingIndexHtmlRequestListener.collectServerViews(RouteUnifyingIndexHtmlRequestListener.java:191)
        at com.vaadin.hilla.route.RouteUnifyingIndexHtmlRequestListener.modifyIndexHtmlResponse(RouteUnifyingIndexHtmlRequestListener.java:114)
        at com.vaadin.flow.server.VaadinService.lambda$modifyIndexHtmlResponse$5(VaadinService.java:619)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
        at com.vaadin.flow.server.VaadinService.modifyIndexHtmlResponse(VaadinService.java:618)
        at com.vaadin.flow.server.communication.IndexHtmlRequestHandler.synchronizedHandleRequest(IndexHtmlRequestHandler.java:200)
        at com.vaadin.flow.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:40)
        at com.vaadin.flow.server.VaadinService.handleRequest(VaadinService.java:1584)
        at com.vaadin.flow.server.VaadinServlet.service(VaadinServlet.java:398)
        at com.vaadin.quarkus.QuarkusVaadinServlet.service(QuarkusVaadinServlet.java:84)
        at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:614)
        at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)
        at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:63)
        at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)
        at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
        at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:67)
        at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:133)
        at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
        at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:65)
        at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
        at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
        at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
        at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:247)
        at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:111)
        at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:108)
        at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
        at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
        at io.quarkus.undertow.runtime.UndertowDeploymentRecorder$9$1.call(UndertowDeploymentRecorder.java:645)
        at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227)
        at io.undertow.servlet.handlers.ServletInitialHandler.handleRequest(ServletInitialHandler.java:152)
        at io.undertow.server.handlers.CanonicalPathHandler.handleRequest(CanonicalPathHandler.java:49)
        at io.quarkus.undertow.runtime.UndertowDeploymentRecorder$1.handleRequest(UndertowDeploymentRecorder.java:126)
        at io.undertow.server.Connectors.executeRootHandler(Connectors.java:284)
        at io.undertow.server.DefaultExchangeHandler.handle(DefaultExchangeHandler.java:18)
        at io.quarkus.undertow.runtime.UndertowDeploymentRecorder$5$2.run(UndertowDeploymentRecorder.java:445)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
        at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:635)
        at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2516)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2495)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1521)
        at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:11)
        at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:11)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.base/java.lang.Thread.run(Thread.java:1583)

2024-10-31 09:34:34,994 ERROR [io.und.req.io] (executor-thread-1) Exception handling request 9fbb9cb5-42bc-4d73-b1ea-a45e5fb2b20a-1 to /: jakarta.servlet.ServletException: com.vaadin.flow.server.ServiceException: java.lang.IllegalArgumentException: Unable to create an instance of 'com.vaadin.flow.server.auth.MenuAccessControl'. Make sure the class has a public no-arg constructor.
        at com.vaadin.flow.server.VaadinServlet.service(VaadinServlet.java:400)
        at com.vaadin.quarkus.QuarkusVaadinServlet.service(QuarkusVaadinServlet.java:84)
        at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:614)
        at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)
        at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:63)
        at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)
        at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
        at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:67)
        at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:133)
        at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
        at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:65)
        at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
        at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
        at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
        at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:247)
        at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:111)
        at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:108)
        at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
        at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
        at io.quarkus.undertow.runtime.UndertowDeploymentRecorder$9$1.call(UndertowDeploymentRecorder.java:645)
        at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227)
        at io.undertow.servlet.handlers.ServletInitialHandler.handleRequest(ServletInitialHandler.java:152)
        at io.undertow.server.handlers.CanonicalPathHandler.handleRequest(CanonicalPathHandler.java:49)
        at io.quarkus.undertow.runtime.UndertowDeploymentRecorder$1.handleRequest(UndertowDeploymentRecorder.java:126)
        at io.undertow.server.Connectors.executeRootHandler(Connectors.java:284)
        at io.undertow.server.DefaultExchangeHandler.handle(DefaultExchangeHandler.java:18)
        at io.quarkus.undertow.runtime.UndertowDeploymentRecorder$5$2.run(UndertowDeploymentRecorder.java:445)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
        at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:635)
        at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2516)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2495)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1521)
        at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:11)
        at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:11)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: com.vaadin.flow.server.ServiceException: java.lang.IllegalArgumentException: Unable to create an instance of 'com.vaadin.flow.server.auth.MenuAccessControl'. Make sure the class has a public no-arg constructor.
        at com.vaadin.flow.server.VaadinService.handleExceptionDuringRequest(VaadinService.java:1645)
        at com.vaadin.flow.server.VaadinService.handleRequest(VaadinService.java:1596)
        at com.vaadin.flow.server.VaadinServlet.service(VaadinServlet.java:398)
        ... 41 more
Caused by: java.lang.IllegalArgumentException: Unable to create an instance of 'com.vaadin.flow.server.auth.MenuAccessControl'. Make sure the class has a public no-arg constructor.
        at com.vaadin.flow.internal.ReflectTools.createProxyInstance(ReflectTools.java:520)
        at com.vaadin.flow.internal.ReflectTools.createInstance(ReflectTools.java:452)
        at com.vaadin.flow.di.DefaultInstantiator.create(DefaultInstantiator.java:198)
        at com.vaadin.flow.di.DefaultInstantiator.getOrCreate(DefaultInstantiator.java:72)
        at com.vaadin.quarkus.QuarkusInstantiator.lambda$getOrCreate$2(QuarkusInstantiator.java:77)
        at com.vaadin.quarkus.BeanLookup.lookupOrElseGet(BeanLookup.java:94)
        at com.vaadin.quarkus.QuarkusInstantiator.getOrCreate(QuarkusInstantiator.java:76)
        at com.vaadin.flow.di.Instantiator.getMenuAccessControl(Instantiator.java:217)
        at com.vaadin.hilla.route.RouteUnifyingIndexHtmlRequestListener.collectServerViews(RouteUnifyingIndexHtmlRequestListener.java:191)
        at com.vaadin.hilla.route.RouteUnifyingIndexHtmlRequestListener.modifyIndexHtmlResponse(RouteUnifyingIndexHtmlRequestListener.java:114)
        at com.vaadin.flow.server.VaadinService.lambda$modifyIndexHtmlResponse$5(VaadinService.java:619)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
        at com.vaadin.flow.server.VaadinService.modifyIndexHtmlResponse(VaadinService.java:618)
        at com.vaadin.flow.server.communication.IndexHtmlRequestHandler.synchronizedHandleRequest(IndexHtmlRequestHandler.java:200)
        at com.vaadin.flow.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:40)
        at com.vaadin.flow.server.VaadinService.handleRequest(VaadinService.java:1584)
        ... 42 more

Expected behavior Again, this could be 110% user error here, but I've been banging my head against my desk for a day now and I can't figure out how to move forward.

Context (please complete the following information):

mcollovati commented 3 weeks ago

IIRC Menu Access Control support has been added in quarkus hilla 24.5. Could you try with the beta version?

edeandrea commented 3 weeks ago

i think that does it! I bumped quarkus-hilla to 24.5.0-beta1 and vaadin to 24.5.2 and it works!

well, the UI comes up, but other things are broken, but I'm definitely further along!

mcollovati commented 3 weeks ago

For the record, in Vaadin 24.4 MenuAccessControl is used only by Hilla, that is currently not supported by the official extension. In Vaadin 24.5 the class is used also in Flow, so the related vaadin-quarkus version has been updated to support the change, but it has not been back-ported.

https://github.com/vaadin/quarkus/pull/176#issuecomment-2413079453

mcollovati commented 3 weeks ago

@edeandrea thank you for giving this extension a try. Please let us know if you need any help with the porting of Marcus project.

edeandrea commented 3 weeks ago

Thank you @mcollovati for the help! This is the first time I've dipped my toes into Vaadin or Hilla, so I'm quite a newbie. Quarkus, LangChain4j, Spring, etc, I'm all good.

I have it (somewhat) working now, but whats not working seems to be the error handling. For example, the original implementation throws some IllegalArgumentExceptions under certain circumstances, for instance:

https://github.com/marcushellberg/java-ai-playground/blob/4358893939ce3043cf5432a81f3aff506bdb0fb7/src/main/java/org/vaadin/marcus/service/FlightService.java#L67

When trying to replicate this with Quarkus I'm seeing the 500 error propagate back to the browser:

image

image

image

and I'm not quite sure what the right "fix" is. Sure I could handle it on the browser side, but it isn't currently handled on the browser side in the Spring version, so I'm curious where the error handling is happening.

mcollovati commented 3 weeks ago

Is your branch updated? Maybe I can take a look

edeandrea commented 3 weeks ago

It is now. By default it needs an OpenAI key, but if you have Ollama installed you can run ./mvnw clean quarkus:dev -Dquarkus.profile=ollama

image

2024-10-31 15:18:46,966 ERROR [com.vaa.hil.EndpointInvoker] (executor-thread-3) Endpoint AssistantService method chat execution failure

Exception in FlightService.java:68
           66                  .filter(b -> b.getCustomer().getLastName().equalsIgnoreCase(lastName))
           67                  .findFirst()
        -> 68                  .orElseThrow(() -> new IllegalArgumentException("Booking not found"));
           69      }
           70  

Exception in FlightService.java:68
           66                  .filter(b -> b.getCustomer().getLastName().equalsIgnoreCase(lastName))
           67                  .findFirst()
        -> 68                  .orElseThrow(() -> new IllegalArgumentException("Booking not found"));
           69      }
           70  

Exception in FlightService.java:72
           70  
           71      public BookingDetails getBookingDetails(String bookingNumber, String firstName, String lastName) {
        -> 72          var booking = findBooking(bookingNumber, firstName, lastName);
           73          return toBookingDetails(booking);
           74      }

Exception in LangChain4jTools.java:26
           24              """)
           25      public BookingDetails getBookingDetails(String bookingNumber, String firstName, String lastName) {
        -> 26          return service.getBookingDetails(bookingNumber, firstName, lastName);
           27      }
           28  

Exception in AssistantService.java:19
           17  
           18      public String chat(String chatId, String userMessage) {
        -> 19          return langChain4JAssistant.chat(chatId, userMessage);
           20      }
           21  }

: java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:118)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at com.vaadin.hilla.EndpointInvoker.invokeVaadinEndpointMethod(EndpointInvoker.java:454)
        at com.vaadin.hilla.EndpointInvoker.invoke(EndpointInvoker.java:203)
        at com.vaadin.hilla.EndpointController.doServeEndpoint(EndpointController.java:251)
        at com.vaadin.hilla.EndpointController.serveEndpoint(EndpointController.java:199)
        at com.github.mcollovati.quarkus.hilla.QuarkusEndpointController.serveEndpoint(QuarkusEndpointController.java:79)
        at com.github.mcollovati.quarkus.hilla.QuarkusEndpointController$quarkusrestinvoker$serveEndpoint_19ea4aa8e36421f8414cd9ce9157408f2c9d0890.invoke(Unknown Source)
        at org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:29)
        at org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:7)
        at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.invokeHandler(AbstractResteasyReactiveContext.java:231)
        at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:147)
        at org.jboss.resteasy.reactive.server.handlers.RestInitialHandler.beginProcessing(RestInitialHandler.java:48)
        at io.quarkus.resteasy.reactive.server.servlet.runtime.ResteasyReactiveServlet.service(ResteasyReactiveServlet.java:31)
        at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:614)
        at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)
        at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:63)
        at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)
        at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
        at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:67)
        at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:133)
        at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
        at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:65)
        at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
        at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
        at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
        at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:247)
        at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:111)
        at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:108)
        at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
        at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
        at io.quarkus.undertow.runtime.UndertowDeploymentRecorder$9$1.call(UndertowDeploymentRecorder.java:645)
        at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227)
        at io.undertow.servlet.handlers.ServletInitialHandler.handleRequest(ServletInitialHandler.java:152)
        at io.undertow.server.handlers.CanonicalPathHandler.handleRequest(CanonicalPathHandler.java:49)
        at io.quarkus.undertow.runtime.UndertowDeploymentRecorder$1.handleRequest(UndertowDeploymentRecorder.java:126)
        at io.undertow.server.Connectors.executeRootHandler(Connectors.java:284)
        at io.undertow.server.DefaultExchangeHandler.handle(DefaultExchangeHandler.java:18)
        at io.quarkus.undertow.runtime.UndertowDeploymentRecorder$5$2.run(UndertowDeploymentRecorder.java:445)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
        at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:635)
        at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2516)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2495)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1521)
        at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:11)
        at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:11)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: java.lang.IllegalArgumentException: Booking not found
        at org.vaadin.marcus.service.FlightService.lambda$findBooking$4(FlightService.java:68)
        at java.base/java.util.Optional.orElseThrow(Optional.java:403)
        at org.vaadin.marcus.service.FlightService.findBooking(FlightService.java:68)
        at org.vaadin.marcus.service.FlightService.getBookingDetails(FlightService.java:72)
        at org.vaadin.marcus.service.FlightService_ClientProxy.getBookingDetails(Unknown Source)
        at org.vaadin.marcus.langchain4j.LangChain4jTools.getBookingDetails(LangChain4jTools.java:26)
        at org.vaadin.marcus.langchain4j.LangChain4jTools_ClientProxy.getBookingDetails(Unknown Source)
        at org.vaadin.marcus.langchain4j.LangChain4jTools$$QuarkusInvoker$getBookingDetails_c9de469e11ecf91bd37ed7d4fda40fa527ff3a5d.invoke(Unknown Source)
        at io.quarkiverse.langchain4j.runtime.tool.QuarkusToolExecutor.execute(QuarkusToolExecutor.java:48)
        at io.quarkiverse.langchain4j.runtime.trkusToolExecutorFactory$1$1.apply(QuarkusToolExecutorFactory.java:37)
        at io.quarkiverse.langchain4j.runtime.tool.QuarkusToolExecutorFactory$1$1.apply(QuarkusToolExecutorFactory.java:34)
        at io.quarkiverse.langchain4j.runtime.tool.ToolSpanWrapper.wrap(ToolSpanWrapper.java:26)
        at io.quarkiverse.langchain4j.runtime.tool.QuarkusToolExecutorFactory$1$2.apply(QuarkusToolExecutorFactory.java:46)
        at io.quarkiverse.langchain4j.runtime.tool.QuarkusToolExecutorFactory$1$2.apply(QuarkusToolExecutorFactory.java:43)
        at io.quarkiverse.langchain4j.runtime.tool.QuarkusToolExecutorFactory$1.execute(QuarkusToolExecutorFactory.java:52)
        at io.quarkiverse.langchain4j.runtime.aiservice.AiServiceMethodImplementationSupport.doImplement(AiServiceMethodImplementationSupport.java:284)
        at io.quarkiverse.langchain4j.runtime.aiservice.AiServiceMethodImplementationSupport.implement(AiServiceMethodImplementationSupport.java:122)
        at io.quarkiverse.langchain4j.runtime.aiservice.MethodImplementationSupportProducer$1$1.apply(MethodImplementationSupportProducer.java:31)
        at io.quarkiverse.langchain4j.runtime.aiservice.MethodImplementationSupportProducer$1$1.apply(MethodImplementationSupportProducer.java:28)
        at io.quarkiverse.langchain4j.runtime.aiservice.SpanWrapper.wrap(SpanWrapper.java:32)
        at io.quarkiverse.langchain4j.runtime.aiservice.MethodImplementationSupportProducer$1$2.apply(MethodImplementationSupportProducer.java:40)
        at io.quarkiverse.langchain4j.runtime.aiservice.MethodImplementationSupportProducer$1$2.apply(MethodImplementationSupportProducer.java:37)
        at io.quarkiverse.langchain4j.runtime.aiservice.MethodImplementationSupportProducer$1.implement(MethodImplementationSupportProducer.java:46)
        at org.vaadin.marcus.langchain4j.LangChain4jAssistant$$QuarkusImpl.chat(Unknown Source)
        at org.vaadin.marcus.langchain4j.LangChain4jAssistant$$QuarkusImpl_ClientProxy.chat(Unknown Source)
        at org.vaadin.marcus.client.AssistantService.chat(AssistantService.java:19)
        at org.vaadin.marcus.client.AssistantService_ClientProxy.chat(Unknown Source)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
        ... 53 more
edeandrea commented 3 weeks ago

I think I figured it out. I think because its just throwing IllegalArgumentException rather than something else that the Quarkus LangChain4j tool invocation isn't handling it properly. When I switch to use some custom exceptions:

public class Exceptions {
    public static class BookingCannotBeChangedException extends RuntimeException {
        public BookingCannotBeChangedException(String bookingNumber) {
            super("Booking %s cannot be changed within 24 hours of the start date".formatted(bookingNumber));
        }
    }

    public static class BookingCannotBeCancelledException extends RuntimeException {
        public BookingCannotBeCancelledException(String bookingNumber) {
            super("Booking %s cannot be cancelled within 48 hours of the start date".formatted(bookingNumber));
        }
    }

    public static class BookingNotFoundException extends RuntimeException {
        public BookingNotFoundException(String bookingNumber) {
            super("Booking %s not found".formatted(bookingNumber));
        }
    }
}

Everything seems to work fine

mcollovati commented 3 weeks ago

Great catch!

edeandrea commented 3 weeks ago

I got it all to work, and even got some Playwright tests to verify the components all work.

Thanks for the help!