Question

I've got problem running JSF 2.0 Portlet in Websphere Portal 8. If I don't use <f:ajax> tag it looks like application works somehow. But when I add <f:ajax> portlet is not rendered and in SystemOut.log I can see:

0000003c FaceletViewDe E   Error Rendering View[/views/Home.xhtml]
                                 java.lang.NullPointerException
    at com.ibm.faces20.portlet.util.WebXMLParser.endElement(WebXMLParser.java:115)
    at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
    at javax.xml.parsers.SAXParser.parse(Unknown Source)
    at com.ibm.faces20.portlet.util.WebXMLParser.<init>(WebXMLParser.java:51)
    at com.ibm.faces20.portlet.httpbridge.PortletResource.getRequestPath(PortletResource.java:106)
    at org.apache.myfaces.shared_impl.renderkit.html.util.ResourceUtils.renderDefaultJsfJsInlineIfNecessary(ResourceUtils.java:204)
    at org.apache.myfaces.shared_impl.renderkit.html.HtmlTextRendererBase.encodeEnd(HtmlTextRendererBase.java:69)
    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:535)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:626)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:622)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:622)
...

I've configured application to use IBM Portlet bridge included in WebSphere Application Server 8. In faces-config.xml I added:

<view-handler>com.ibm.faces20.portlet.FaceletPortletViewHandler</view-handler>
<resource-handler>com.ibm.faces20.portlet.httpbridge.PortletResourceHandler</resource-handler>
<el-resolver>com.ibm.faces20.portlet.PortletELResolver</el-resolver>

In portlet.xml I use IBM classes like:

...
<portlet-class>com.ibm.faces20.portlet.FacesPortlet</portlet-class>
<init-param>
    <name>com.ibm.faces.portlet.page.view</name>
    <value>/views/Home.xhtml</value>
</init-param>
...

I found out that when I remove <resource-handler>com.ibm.faces20.portlet.httpbridge.PortletResourceHandler</resource-handler> from faces-config.xml application works even with tags. But than jsf.js is missing so all AJAX JavaScript calls fails. Thus application acts like if no is present.

I would be gratefull for any help or advice.

I'm trying to make JSF 2.0 portlets run on WebSphere Portal 8 for 5 days now, with almost no success and lot of pain. It's very difficult with little documentation, no sources (I have to decompile classes!). Crappy proprietary closed-source!

Was it helpful?

Solution

Ok the problem was in declaration of Faces Servlet in web.xml. The name of Faces Servlet is very important in WebSphere Portal 8. It has to be exactly

Faces Servlet

with exact case. Like this:

<servlet>
    <description>
        Servlet that does the job for serving JSF requests.
    </description>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    <enabled>true</enabled>
    <async-supported>false</async-supported>
</servlet>

If you don't keep to this servlet name obscure exceptions are thrown as written above. This behavior is very strange and incomprehensible for me. Didn't found anything about Faces Servlet canonical name. I'm not sure if any other Portal server requires anything like this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top