Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Chaminda Amarasinghe
Websphere, Liferay, Myfaces, Primefaces
December 16, 2012 6:27 AM
Answer

Chaminda Amarasinghe

Rank: New Member

Posts: 22

Join Date: December 16, 2012

Recent Posts

Hi Friends,

I have a Simple Hello World JSF portlet which runs on Websphere 8. For UIs I have used Primefaces 3.4, on Mojarra. In Webshpere terms to acheive that I have to used isolated shared library for Mojarra Implementation jars since websphere default implementation is Myfaces. Everything works fine.

But befause of business requirement, I have to had change the Mojarra jsf implementation to default Myfaces implemetation.

I have made the following changes to my exising (working) portlets.

1. web.xml
change the listener for mysfaces

<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>


2. faces-config.xml
added factory and view hander as follows,

<factory>
<faces-context-factory>com.liferay.util.bridges.jsf.myfaces.MyFacesContextFactoryImpl</faces-context-factory>
</factory>
<application>
<view-handler>com.sun.facelets.FaceletPortletViewHandler</view-handler>
</application>


3. Added myfaces implementation jars to lib,

With these changers when I try to access portlet I am getting following exception,

Exception created : [javax.portlet.faces.BridgeException: java.lang.VerifyError: org.apache.myfaces.context.servlet.ServletFacesContextImpl
at com.liferay.faces.bridge.BridgePhaseRenderImpl.execute(BridgePhaseRenderImpl.java:91)
at com.liferay.faces.bridge.BridgeImpl.doFacesRequest(BridgeImpl.java:100)
at javax.portlet.faces.GenericFacesPortlet.doView(GenericFacesPortlet.java:255)
at javax.portlet.GenericPortlet.doDispatch(GenericPortlet.java:328)
at javax.portlet.faces.GenericFacesPortlet.doDispatch(GenericFacesPortlet.java:204)
at javax.portlet.GenericPortlet.render(GenericPortlet.java:233)
at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:100)
at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:64)
at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:111)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1224)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:774)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:456)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:136)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:97)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:72)
...................


If I remove above factory and view hander above from faces-config, I am getting folloing exception


[12/16/12 19:45:34:178 IST] 0000003f ExternalConte I Portlet Environment Detected: 2.0
[12/16/12 19:45:34:990 IST] 0000003f FaceletViewDe E Error Rendering View[/views/view.xhtml]
java.lang.ClassCastException: com.liferay.portlet.RenderResponseImpl incompatible with javax.servlet.ServletResponse
at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.createResponseWriter(FaceletViewDeclarationLanguage.java:1552)
at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.renderView(FaceletViewDeclarationLanguage.java:1297)
at org.apache.myfaces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:263)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:59)
at com.liferay.faces.bridge.application.ViewHandlerCompatImpl.renderView(ViewHandlerCompatImpl.java:35)
at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:85)
at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:239)
at com.liferay.faces.bridge.lifecycle.LifecycleWrapper.render(LifecycleWrapper.java:45)
at com.liferay.faces.bridge.BridgePhaseRenderImpl.execute(BridgePhaseRenderImpl.java:227)
at com.liferay.faces.bridge.BridgePhaseRenderImpl.execute(BridgePhaseRenderImpl.java:85)
at com.liferay.faces.bridge.BridgeImpl.doFacesRequest(BridgeImpl.java:100)
at javax.portlet.faces.GenericFacesPortlet.doView(GenericFacesPortlet.java:255)
..............................................


Please note that in both cases I am not getting any deployment errors. I have not added any myfaces portlet bridge jars other than liferay default. portlet class is <portlet-class>javax.portlet.faces.GenericFacesPortlet</portlet-class>

Is this doable? Is there any other configurations ? jars needed be added?
Can someone help me to ge this done?

Best Regards,
Chaminda
Chaminda Amarasinghe
RE: Websphere, Liferay, Myfaces, Primefaces
December 16, 2012 6:31 AM
Answer

Chaminda Amarasinghe

Rank: New Member

Posts: 22

Join Date: December 16, 2012

Recent Posts

Please note that liferay version is 6.1.1.-ce-ga2
Neil Griffin
RE: Websphere, Liferay, Myfaces, Primefaces
December 17, 2012 7:44 AM
Answer

Neil Griffin

LIFERAY STAFF

Rank: Liferay Legend

Posts: 2351

Join Date: July 26, 2005

Recent Posts

The com.liferay.util.bridges.jsf.myfaces.MyFacesContextFactoryImpl is a legacy feature for JSF 1.x and is not necessary in a JSF 2.x portlet.

Additionally, the com.sun.facelets.FaceletPortletViewHandler is something was required to get the old Facelets project to work with JSF 1.x, and is not necessary in a JSF 2.x portlet.

In order to see if you can get MyFaces working in general with PrimeFaces, I would recommend that you download the primefaces3-portlet demo and replace the Mojarra jsf-api and jsf-impl JARs with the MyFaces myfaces-api and myfaces-impl JARs. I would further recommend that you try version 2.1.8.

One thing I would point out, is that the faces-config.xml file for the primefaces3-portlet demo has an entry for the Liferay Faces ViewScopePhaseListener, which helps with a MyFaces related issue. For more information, see the JavaDoc comments of ViewScopePhaseListener.java
Chaminda Amarasinghe
RE: Websphere, Liferay, Myfaces, Primefaces
December 17, 2012 8:49 AM
Answer

Chaminda Amarasinghe

Rank: New Member

Posts: 22

Join Date: December 16, 2012

Recent Posts

Hi Neil,

Thanks for the quick response and explainations. I will try with demo and let you know.

Regards,
Chaminda