gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 11:14:20 25 4
gpt4 key购买 nike

我有一个 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 Enhanced) 7.0”。

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

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

When I open a page containing this portlet in a browser, the expected content seems to render correctly, but links in the content don't do anything.
Every load of the page produces this stack trace in "SystemOut.log" on the server, which I've truncated somewhat:

[14/08/15 13:52:27:826 EST] 00000158 ServletWrappe E com.ibm.ws.webcontainer.servlet.ServletWrapper serviceCWSRV0068E: 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)    ...

I assume some other error has triggered Error.jsp but, if so, the initial error doesn't appear in log files or in the browser.
What might cause the NullPointerException in Error.jsp, and how can I fix it?

I suspect it's a configuration issue, but the full content of Error.jsp is below in case that's any help.
MHFacesPortlet used in Error.jsp is a custom class that extends 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>

关于java - WebSphere Portal 8.5 - Portlet 应用程序 - Error.jsp 的服务方法抛出 NullPointerException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32004351/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com