VaadinServlet.getCurrent returns null

165 views Asked by At

I have a Vaadin7 application I am trying to move to Vaadin12 and there is a line of code where I call VaadinServlet.getCurrent() to get the servlet ( I actually need to configuration information ). It is returning null. What is happening and how can I fix?

Obviously, this line of code works fine in Vaadin7.

1

There are 1 answers

0
Tony B On BEST ANSWER

Ok, it was a simple solution: I just had to change import com.vaadin.server.VaadinServlet; to import com.vaadin.flow.server.VaadinServlet;. There is a addon we use that seems to reference vaadin 7 stuff, and thus neither of us noticed the wrong import statement. Either we should have stopped using this addon or updated it to the latest version.

Lesson to learn from this: make sure you are no referencing Vaadin 7 via depencies in your pom, I guess.