Application.getContext() Returning Null

Good Morning Vaadin-ers,

I’m hoping that someone else in the community has experienced this and has a solution for a problem that we’re facing. We’re building a pretty large scale application here and are fairly early on in the process. However, in the init() method of our main Vaadin application class we attempt to initialize an ApplicationContextHelper to allow us to integrate our application with Spring. This works about 80% of the time, but sometimes the call to Application.getContext() returns null causing an NPE to be raised in our ApplicationContextHelper and bringing the app to its knees.

Here’s a little overview of the technical specs under which we’ve experienced this:


  • Tomcat 6 as well as Resin 4

Vaadin Version:




We are utilizing PingIdentity for SSO and that’s the only authentication layer fronting the Vaadin app. Once an end user has successfully authenticated we proceed to build out the app, but it occasionally trips over itself due to getContext() returning null.


In general, this should not happen. The getContext method should return an instance of ApplicationContext. They can be different type depending on which kind of environment we are running, but WebApplicationContext is the type in a servlet-based system. ClassCastExceptions I have seen because of application deployed in different environments, but not NPE.

So, most likely this has something to do with Spring injections. Also, take a look at possible thread local variables that might be still uninitialized.

If you have a stack trace available, that could help locating the problem.