-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot invoke "com.vaadin.flow.server.StaticFileHandler.serveStaticResource(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)" because "this.staticFileHandler" is null #15991
Comments
Possibly your embedded Jetty is not correctly configured to invoke all registered listeners like servletcontextlisteners |
Okey thanks for the reply, I will check out if I can fix this problem 👍 |
Related conversations/tickets: Discord:
Expertise: No solution yet in these places yet. Anyone here? |
I have no solution yet, I tried to recreate the VaadinBoot Server Init but had no luck. The same error remains. I will check if I am allowed to make a small project where the error still appears. |
@TimurUgurlu Thanks for your prompt reply. This issue is tricky, so far I did not see or be aware of any solutions for the affected (not many fortunately, but still a problem for 2-5 I know) customers. A small (GitHub) project, where the issue can be reproduced would be more than helpful! 🙏 |
Maybe the following will bring the issue a step further to fixing the issue: Somehow I managed to load Vaadin with "no errors" using VaadinBoot with AppShell Class and Main Class with standard Vaadin Servlet. I took a sample Class from Vaadin Homepage and added an empty Route but it is not registered. I think it is a classpath error now? It can load all the Vaadin Stuff but not the actual Views? Found this old thread on Vaadin Forums that has the same problem with Flow but the fix in the last answer didn't work: EDIT: Running from Eclipse gtse me the Route error, running "gradlew run" in cmd gets me staticFileHandler error I really dont know what is going on |
Hey, It is not clear to me, whether you used VaadinBoot fully, or you added some customer servlet to your project, or you try to combine your project with VaadinBoot. If you could upload your project somewhere, I think more ppl could look into it, it would be super helpful. Also, the solution in the forum is for V14 and you have the issue for V23, so it can cause that it is not working :( |
I tried to reproduce the issue with this sample project using Gradle, V23, and the embedded Jetty, but the project worked fine. Can you try my project and suggest changes to it such that the issue will reproduce? https://github.com/johannest/vaadin-embedded-jetty-gradle-v23 |
@TimurUgurlu if you intended to run the project in dev mode, please set |
Ohh next time I should read the Readme 🤦♂️ It worked now. I will try to reproduce the error now, hope it works out somehow. |
I took the default project from start.vaadin.com and converted it from Spring Boot into using an embedded Jetty: https://github.com/Artur-/vaadin24-embedded-jetty If you leave out the then you will get
on startup because the listeners are not found and invoked on startup |
Thank you @Artur- for reproducing it. I came to the same conclusion in the relevant JIRA ticket that this line is super important (with some insights from Martin Vyšný), but could not reproduce it, and shared this solution with the customer, but big lesson JIRA formatted it, and only after I sent push click :S, so it was missing some characters. Anyway, I got back to the customer to correct my mistake now, and I hope this will solve the original issue for them in their case as well (harder, because we do not have access to their codebase so can only give hints, and ideas). |
The reason for the original NPE is that the To fix this, you have to enable Jetty classpath scanning with the Please read more here: https://mvysny.github.io/vaadin-lookup-vs-instantiator/ |
@TimurUgurlu does set the |
I am still stuck here: |
@TimurUgurlu could you put a breakpoint in |
@mcollovati Looks like the issue still reproduces when running the app through (fat) jar with dependencies. I forked Artur's project and changed the pom.xml such that it would create a fat jar: https://github.com/johannest/vaadin24-embedded-jetty. When running it: The same issue happens also with Gradle if running the jar directly. However if running it through Gradle distribution's generated shell script it works fine. The Gradle generated shell script creates a |
Few more comments. We got this working both with Maven project and Gradle project.
Note! Using these shade/shadow plugins is maybe not the best practice since they basically extract every dependency to root of the jar files which is prone to error. That was actually the principal reason why this failed before: when the fat jar is built the one of dependencies overrides META-INF/service/jakarta.servlet.ServletContainerInitializer and thus Vaadin lookup (SPI) is never initialized. The better way would be using Spring Boot jar or Gradle distribution plugin which keep the dependencies in their own jar files. I think this ticket can be closed now. |
Thanks, @johannest, for the update. |
It strikes again :-( Vaadin: 24.4.11 Jetty 11.0.24 Everything done by the book, as shown in the previous comments
It may be something Jetty related because with Jetty 11.0.14 works ... |
@cliviu if you can provide a reproducible example, please create a new issue, so that we can better track the problem |
Somehow, starting with Jetty 11.0.16 the LookupServletContainerInitializer is not found. Jetty 11.0.15 is the last version where it works. I am not sure where the problem is. |
Just for the record, if somebody bumps into it : starting with version 11.0.16 |
Description of the bug
So I am not exactly sure if it is a bug or not but I am struggling with updating Vaadin 8 to Vaadin 23.
I already contacted your Discord Support but had no luck.
We are using Vaadin 8 which we customized a lot to have the expected user experience.
Our environment is: Gradle 7 (latest), Java 17, embedded Jetty 10.0.12, Vaadin 8 (want to upgrade to 23)
To have a little inside in our project:
Updating to Vaadin 23
But now we are getting this error you see below and I have no idea why this happens. I try to register the servlet correctly but I thinks its not correct.
I already got a sample project for Vaadin Boot from one of Vaadin Support Members but I had no luck to implement the same behaviour.
If I try to launch our Web Application i get this error:
HTTP ERROR 500 java.lang.NullPointerException: Cannot invoke "com.vaadin.flow.server.StaticFileHandler.serveStaticResource(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)" because "this.staticFileHandler" is null
Caused by:
Expected behavior
A view should be shown
Minimal reproducible example
None, our project is too complex to share some example
Versions
The text was updated successfully, but these errors were encountered: