staticFileHandler is null (VaadinServlet)

Hey I am trying to migrate Vaadin 8 to Vaadin 23

When I try to launch my app I get this error https://pastebin.com/raw/nqNuB3QA

I tried manual and automatic registration of the Servlet but somehow it never calls createStaticFileHandler method to create a fileHandler.
I am using Java 17, Gradle 7.6 and Jetty 10

I dont know if the Servlet is the problem or there might be something else wrong

Or maybe some kind of misconfiguration?

Are you able to share the project?
There was an issue with Jetty time ago: in some situations Servlet.service was invoked before Servlet.init completed, but it should have been fixed in 9.4.25, sot there should be something different here

unfortunately i cant share the project because its for the company i am working for, i am on the latest jetty version (10.0.13)

I assume the bug shouldnt appear or am i wrong? i could test it tomorrow with 9.4.25

maybe i can share some snippets but i would need to know what you need or where the problem may be

is there maybe any example of how to migrate a servlet from 8 to 23 because all i read is that servlets are registered automatically now and are not needed
i saw that the VaadinServletConfiguration is deprecated and can be migrated with a WebServlet annotation what i did, i tried to only change the most things that lead to compile errors so i can keep track of what can and can not be a problem

To give you some information: We have a UI class which extends to a UI (which is also not needed anymore) that has a Subclass with a simple servlet.

We add a title and some other meta data and load a custom coded Login class without Routing at the moment because all we do is actually keep on the same page and switch the content

In the error logs there is the given error which i submitted on the pastebin and i think it tries to load a favicon.ico but fails.
Can it be because of some misconfiguration or a missing file or just because it cant instantiate the StaticFileHandler?

It is hard to say what it may be the cause. Did you tried to debug the init method? Is it not invoked at all or does it exit before the createStaticFileHandler?
You can also add a break point to the LookupInitializer and check if it is executed

How can I debug the init method?

Its not possible for me to do it with my IDE because I need to build the app first so I can start the server and then the web application

Can I log the VaadinServlet maybe?

Can’t you attach the IDE debugger to the servlet container?
If you start the server with, for example, -Xdebug -Xrunjdwp:transport=dt_socket,address=5005,suspend=y the server should wait until you attach the debugger to port 5005 before start, so you should be able to hit the break point in Servlet init method

I am Peter from the Support ticket, you opened yesterday night.
How is it going with the debug @visionary-vespa ?
Could you share the pom.xml maybe or not even that is allowed?

Also just to make sure you did do the necessary steps mentioned here?
https://vaadin.com/docs/latest/advanced/application-lifecycle#application.lifecycle.deployment

“It’s only necessary to have at least one class that carries the @Route annotation. A VaadinServlet instance is registered for you automatically and Vaadin registers all the required servlets automatically.”

"The servlet isn’t registered if any VaadinServlet is already registered, or if there is no class annotated with the @Route annotation.
Additionally, a servlet isn’t registered if:

  • there is a servlet that has already been mapped to the same path, or
  • if the system property disable.automatic.servlet.registration is set to true"

Would be good to check if you have a web.xml, and check if you have
@WebServlet annotation as well.

Additionally, we could do a screen-sharing session if it is allowed to you and you could show your application in real-time through google meet.

So tldr:

  • You need to have at least one @Route annotation with different route paths,
  • web.xml should not collide with Vaadin servlets,
  • system property (disable.automatic.servlet.registration) mentioned should not be true,
  • and potentially pom.xml could be incorrect,

Also, is there any exception happening in the application startup phase?

I have no web.xml, is there any format for it?

system property is not set

I am using gradle so no pom.xml and I only use all the needed jetty and vaadin dependencies

productionMode is set to false

war is enabled

Taking a look at your servlet: you should not call init method in the constructor. `init’ should be called by the servlet container

Yeah I just added it because i thought it wont call it automatically

Second thing, in Vaadin 23 you are not supposed to subclass UI.
The @Route annotation should be applied to the component that represent the view
The other annotations @Push and @Viewport should be put in a class implementing AppShellConfigurator

Okey i will try to seperate them

Ah you were faster, I wanted to give you @visionary-vespa an example how to create your main/starting class:

The configuration and structure for creating an app quite much changed from V8 to V23, and I am not sure if you can use it anymore like how you used in your shared class.

This example should be deployable as well, so it is a good starting point to compare to your code, but also feel free to ask here or in the ticket. And yes, your starting UI class was very helpful, thanks for sharing! :+1:t2:

@visionary-vespa Please let me know if you made it work or still struggling (either here or even better if in the Jira ticket, you can notify as well). I will be a bit slower as my shift ended, and I will switch to some coding/other more focused tasks from live support. Take care.

Did it solve the problems? I guess and hope it is :slightly_smiling_face:

Well i could implement the Skeleton into our app, it works but now i need to migrate all the classes and I have no clue :joy:

For example we didnt had any routes at all, we always switched contents depending on what we needed interactively

I already noticed that using ClassicComponents needs a Vaadin License even in development mode, which I thought was not needed

We have a License but I am waiting for my senior dev to reply to me so I can check if our License is compatible

I am trying to remove the servlet from our v8 version now maybe there is some easier way to get it working without writing everything new

Yes, but you could have just tried out to add the Appshell class to your application and remove your old VaadinServlet implementation (as said VaadinServlet shall be inited automatically most of the case).

And thanks for getting back :slightly_smiling_face: