org.apache.myfaces.taglib.core.ViewTag.doStartTag中的java.lang.NullPointerException(java.lang.NullPoin

编程入门 行业动态 更新时间:2024-10-21 07:50:02
org.apache.myfaces.taglib.core.ViewTag.doStartTag中的java.lang.NullPointerException(java.lang.NullPointerException at org.apache.myfaces.taglib.core.ViewTag.doStartTag)

我正在使用MyFaces 1.2和WAS 7.0以及Myeclipse Blue 10.7。 我收到以下错误。 我已经彻底研究了互联网,但无济于事。 日志并不多。 MyEclipse没有像IBM RAD那样的JSF跟踪调试实用程序。

[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)

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)

最满意答案

当您通过请求URL打开包含JSF组件的JSP页面时,通常会出现此异常,该请求URL与FacesServlet的URL模式不匹配。 基本上,JSP页面中的JSF组件期望FacesContext可以使用FacesContext#getCurrentInstance() 。 但是,它返回null ,最终导致此NullPointerException 。

请注意,堆栈跟踪也没有提供正确调用FacesServlet任何提示。 调用直接转到容器自己的JSP servlet,在Websphere的情况下是HttpJspBase ,而不是JSF自己的FacesServlet 。

为了解决这个问题,只需在web.xml查看FacesServlet映射到的URL模式。 在JSF 1.x中,这通常是*.jsf或者*.faces或者很可能是/faces/* 。 一旦你想到这一点,只需确保请求URL(如浏览器的地址栏中所示)与该URL模式完全匹配。 所以,而不是例如

http://example.com/context/sui_index.jsp

你应该根据实际的映射使用其中之一

http://example.com/context/sui_index.jsf

要么

http://example.com/context/sui_index.faces

要么

http://example.com/context/faces/sui_index.jsp

无论哪种方式,这样都可以调用FacesServlet并且能够按照JSP页面中的JSF组件的预期正确准备FacesContext 。

也可以看看:

JSF Facelets:有时我看到URL是.jsf,有时是.xhtml。 为什么?

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

http://example.com/context/sui_index.jsp

you should depending on the actual mapping be using either

http://example.com/context/sui_index.jsf

or

http://example.com/context/sui_index.faces

or

http://example.com/context/faces/sui_index.jsp

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.

See also:

JSF Facelets: Sometimes I see the URL is .jsf and sometimes .xhtml. Why?

更多推荐

本文发布于:2023-07-23 18:41:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1235675.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:taglib   core   myfaces   org   apache

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!