且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在WebSphere Portal 8部署JSF 2.0的portlet

更新时间:2023-02-23 13:08:14

好了,问题是在声明的面的Servlet 的web.xml 的名称面临的Servlet 是非常重要的WebSphere Portal中8.必须准确

  

面的Servlet

与确切情况。像这样的:

 <的servlet>
    <描述>
        Servlet的,做的服务JSF请求工作。
    < /描述>
    < servlet的名称>面的Servlet< / Servlet的名称>
    <的servlet类> javax.faces.w​​ebapp.FacesServlet< / Servlet的类>
    &所述;负载上启动→1&其中; /负载上启动>
    <启用>真< /启用>
    <异步支持>假< /异步支持>
< / servlet的>
 

如果你不保持这个servlet名称晦涩异常被抛出上面​​写的。这种行为是非常奇怪和科钦prehensible我。没有发现有关面孔的Servlet规范名称事情。我不知道是否有任何其他门户网站服务器需要这样的事。

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!

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.