简体   繁体   中英

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

I have a JSR 168 portlet application which was originally developed for WebSphere Portal 6.0, then moved to WebSphere Portal 7.0 with the minimum of changes needed to make it work, and now I'm trying to move it to WebSphere Portal 8.5.

I've tested just one of the portlets so far on WP 8.5, using the WP 7.0 version of the app with no changes. It seems to be triggering the app's Error.jsp, which itself produces a NullPointerException in the server log.

The app's project facets include "JavaServer Faces 1.1" and "JavaServer Faces (IBM Enhanced) 7.0".

The portlet I'm testing has a JSP specified as a home page via this element in a portlet element in the "portlet.xml" file in the app:

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

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();
}%>

I have discovered what is triggering Error.jsp, and concluded that the NullPointerException is, as suggested in a comment by Konstantin, caused by Error.jsp not rendering through the portlet.

When using the application in WebSphere Portal 8.5, this tag is added to the HTML:

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

The path in that tag produces a 404 error, which triggers Error.jsp, which then produces a NullPointerException .
The 404 error is also responsible for links failing in the portlet JSP, as they rely on javascript which should be in oamSubmit.js.

I fixed both problems by adding this to the web.xml file:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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