SEVERE: Exception sending context initialized event to listener instance of class + Null Pointer Exception

If at all you are trying to load the bean before, use like below. This is also useful when you try to get a bean in @weblistener  as well.


@Override
public void contextInitialized(ServletContextEvent sce) {
    WebApplicationContextUtils
        .getRequiredWebApplicationContext(sce.getServletContext())
        .getAutowireCapableBeanFactory()
        .autowireBean(this);

    //your code goes here

}