lundi 2 mars 2015

Failed startup of context com.google.appengine.tools.development.DevAppEngineWebAppContext

I am using Spring MVC,google app engine, admin sdk, cloud sql. I want to access (preferncesDao) dao class into Filter. Below is my filter



public class NameSpaceGoogleSecurityFilter implements Filter
{
@Autowired
IPreferencesDao preferncesDao;

public void init( FilterConfig filterConfig ) throws ServletException{
SpringUtils.init(filterConfig.getServletContext());
preferncesDao = SpringUtils.getPreferncesDao();
}
}


Below is my SpringUtils class.



public class SpringUtils {

private static ApplicationContext appContext;

private static IPreferencesDao preferncesDao = null;

public static void init(final ServletConfig config) {
init(config.getServletContext());
}
public static void init(final ServletContext context) {
if(appContext==null){
appContext =
(ApplicationContext) context.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
}
}

public static IPreferencesDao getPreferncesDao() {
if(preferncesDao==null){
preferncesDao=(IPreferencesDao) appContext.getBean("preferncesDao");
}
return preferncesDao;
}

protected SpringUtils() {
throw new UnsupportedOperationException();
}
}


When I start build process, It is throwing below exception



Failed startup of context com.google.appengine.tools.development.DevAppEngineWebAppContext
java.lang.NullPointerException.
Nullpointer at line preferncesDao=(IPreferencesDao) appContext.getBean("preferncesDao");


How can i resolve above error ? is it right way to get dao object into filter ? if not what is correct way.?


Aucun commentaire:

Enregistrer un commentaire