VaadinServlet.getCurrent() returns null!

My Vaadin App works fine with an AppLayout, I also have a Controller Servlet that responds with JSON data. I noticed that when I call VaadinServlet.getCurrent() from this Controller, I get null!

what am I doing wrong?

@RequestMapping(value = "/json")
public class JSONController extends VaadinServlet {
System.err.println("vaddin servlet: "+VaadinServlet.getCurrent());

Prints Null!!

Short answer: not possible

Even though the class extends VaadinServlet?

What is a workaround for this? To share some instance parameters?

Your controller could share e.g. a service or a database with your Vaadin app - but I don’t know what you wanna archive

So basicly they won’t even share a static class instance?

Well that would work but I personally would not use the concept of static classes in a framework like spring and instead use a Singleton Service

VaadinServlet only handles Vaadin requests

If the REST requests are coming from the same browser instance as the Vaadin UI calls, they will share a HTTP session

But generally speaking, @quirky-zebra is right. The answer depends on the problem you’re trying to solve, and static classes are almost never the right solution.