繁体   English   中英

WebSphere Portal 8.5-Portlet应用程序-Error.jsp的服务方法抛出NullPointerException

[英]WebSphere Portal 8.5 - Portlet app - NullPointerException thrown by service method of Error.jsp

我有一个JSR 168 portlet应用程序,该应用程序最初是为WebSphere Portal 6.0开发的,然后以使其工作所需的最少更改移至WebSphere Portal 7.0,现在我正尝试将其移至WebSphere Portal 8.5。

到目前为止,我仅使用WP 7.0版本的应用程序在WP 8.5上仅测试了其中一个portlet,而没有进行任何更改。 它似乎正在触发应用程序的Error.jsp,它本身在服务器日志中生成NullPointerException。

该应用程序的项目方面包括“ JavaServer Faces 1.1”和“ JavaServer Faces(IBM增强)7.0”。

我正在测试的portlet在应用程序的“ portlet.xml”文件中的portlet元素中通过此元素将JSP指定为主页:

<init-param>
    <name>com.ibm.faces.portlet.page.view</name>
    <value>/Admin/AdministratorControlView.jsp</value>
</init-param>

当我在浏览器中打开包含此Portlet的页面时,预期的内容似乎可以正确呈现,但是内容中的链接没有任何作用。
页面的每次加载都会在服务器上的“ SystemOut.log”中生成此堆栈跟踪,我已对其进行了截断:

[14/08/15 13:52:27:826 EST] 00000158 ServletWrappe E com.ibm.ws.webcontainer.servlet.ServletWrapper service
CWSRV0068E: An exception was thrown by one of the service methods of the servlet [/Error.jsp]
in application [PA_TeamElite]. Exception created : [java.lang.NullPointerException
    at com.ibm.ws.portletcontainer.tags.DefineObjectsTag.doStartTag(DefineObjectsTag.java:62)
    at com.ibm._jsp._Error._jspService(_Error.java:105)
    at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:99)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1230)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:779)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
    at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
    ...

我假设其他错误已触发Error.jsp,但如果是这样,则初始错误不会出现在日志文件或浏览器中。
是什么导致Error.jsp中的NullPointerException异常,如何解决?

我怀疑这是一个配置问题,但是Error.jsp的完整内容在下面,以防万一。
MHFacesPortlet使用的MHFacesPortlet是自定义类,该类扩展了com.ibm.faces.portlet.FacesPortlet


<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1" session="false" isErrorPage="true"
    import="com.devcompany.util.portlet.MHFacesPortlet"%>
<portlet:defineObjects />

<%javax.portlet.PortletURL url = renderResponse.createActionURL();
    url.setParameter(MHFacesPortlet.PARAMETER_EXTENDED_ACTION,
        MHFacesPortlet.ACTION_VIEW_MODE_RESET);
%>

<p>The following error has occurred. Click <a href="<%= url.toString()%>">here</a>
to go to the portlet home page.</p>

<%Throwable e = exception;
while (e != null)
{%>
    <%=e.getMessage()%>
    <br>
    <br>
<%
    e.printStackTrace();
    e = e.getCause();
}%>

我发现了触发Error.jsp的原因,并得出结论,如Konstantin的评论所建议, NullPointerException是由Error.jsp无法通过portlet呈现引起的。

在WebSphere Portal 8.5中使用应用程序时,此标签将添加到HTML:

<script type="text/javascript"
src="/wps/PA_AppName/portlet/javax.faces.resource/oamSubmit.js?ln=org.apache.myfaces">

该标记中的路径产生404错误,该错误触发Error.jsp,然后产生NullPointerException
404错误还导致portlet JSP中的链接失败,因为它们依赖于应在oamSubmit.js中的javascript。

通过将其添加到web.xml文件中,我解决了两个问题:

<context-param>
    <param-name>org.apache.myfaces.RENDER_FORM_SUBMIT_SCRIPT_INLINE</param-name>
    <param-value>true</param-value>
    <description></description>
</context-param>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM