java.lang.NullPointerException Sun PetStore CatalogFacade
in the Sun Java PetStore demo index.jsp file, I'm getting a Null Pointer Exception on cf
CatalogFacade cf = (CatalogFacade)getServletContext().getAttribute("CatalogFacade");
List<Tag> tags=cf.getTagsInChunk(0, 12); <--- cf is Null
I'm using Ecl开发者_如何学Pythonipse and I don't know why CatalogFacade is null or how to debug this.
Any clue greatly appreciated.Edit:
In the CatalogFacade
Class which implements ServletContextListener
public void contextInitialized(ServletContextEvent sce) {
ServletContext context = sce.getServletContext();
context.setAttribute("CatalogFacade", this);
}
My first investigation would be to see if getServletContext().getAttribute("CatalogFacade");
returns a null
.
If it does, then you've never stored a CatalogFacade
object in your application. Perhaps look at storing it using getServletContext().setAttribute("CatalogFacade", cf);
?
That's what I can help you with (with the little info you've provided).
精彩评论