I am using MyFaces 1.2 with WAS 7.0 and Myeclipse Blue 10.7. I am getting the following error. I have researched Internet pretty thoroughly but to no avail. Logs don't present much. MyEclipse does not have JSF trace debug utility like IBM RAD.
[8/8/13 10:41:19:447 EDT] 00000018 webapp E com.ibm.ws.webcontainer.webapp.WebApp logServletError SRVE0293E: [Servlet Error]-[/sui_index.jsp]: java.lang.NullPointerException
at org.apache.myfaces.taglib.core.ViewTag.doStartTag(ViewTag.java:75)
at com.ibm._jsp._sui_5F_welcome._jspx_meth_f_view_0(_sui_5F_welcome.java:755)
at com.ibm._jsp._sui_5F_welcome._jspService(_sui_5F_welcome.java:121)
at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:99)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1664)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:940)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:503)
This exception is typical when you open a JSP page containing JSF components by a request URL which does not match the URL pattern of the FacesServlet
. Basically, the JSF components in the JSP page are expecting to the FacesContext
to be available by FacesContext#getCurrentInstance()
. However, it returned null
which in turn ultimately caused this NullPointerException
.
Note that the stack trace also doesn't give any hint that the FacesServlet
is properly been called. The call went directly to the container's own JSP servlet, which is HttpJspBase
in case of Websphere, instead of JSF's own FacesServlet
.
In order to sovle this problem, just look in the web.xml
on which URL pattern the FacesServlet
is been mapped. In JSF 1.x, this is usually *.jsf
or maybe *.faces
or very maybe /faces/*
. Once you figured that, just make sure that the request URL, as you see in browser's address bar, matches exactly that URL pattern. So, instead of for example
you should depending on the actual mapping be using either
or
or
Either way, this way the FacesServlet
will be invoked and be able to properly prepare the FacesContext
as expected by the JSF components in the JSP page.