Foros de discusión

RenderRequestBridgeLiferayImpl cannot be cast to LiferayPortletRequest

Jan Tošovský, modificado hace 6 años.

RenderRequestBridgeLiferayImpl cannot be cast to LiferayPortletRequest

Liferay Master Mensajes: 566 Fecha de incorporación: 22/07/10 Mensajes recientes
Dear All,

after upgrading liferay-faces-bridge-impl from 3.2.4 to 4.2.5 the following cast returns a ClassCastException exception:
ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
LiferayPortletRequest portletRequest = (LiferayPortletRequest) externalContext.getRequest();

I need to pass that LiferayPortletRequest to Asset Renderer.

Is it a regression or something has to be changed on my side? As a last resort I can downgrade back to 3.2.x version.

Thanks,
Jan

LR 6.2
Tomcat 8.0
thumbnail
Vernon Singleton, modificado hace 6 años.

RE: RenderRequestBridgeLiferayImpl cannot be cast to LiferayPortletRequest (Respuesta)

Expert Mensajes: 315 Fecha de incorporación: 14/01/13 Mensajes recientes
Hi Jan,

Jan Tošovskýafter upgrading liferay-faces-bridge-impl from 3.2.4 to 4.2.5 the following cast returns a ClassCastException exception:
ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
LiferayPortletRequest portletRequest = (LiferayPortletRequest) externalContext.getRequest();


Please use our latest released jars instead of the older 4.2.5 jars. There are many fixes in the newer jars for 6.2. You can start by generating one of the maven archetypes for 6.2 using the instructions in the portlet at liferayfaces.org

Jan Tošovský
I need to pass that LiferayPortletRequest to Asset Renderer.

Is it a regression or something has to be changed on my side? As a last resort I can downgrade back to 3.2.x version.

You also might want to use PortalUtil's getLiferayPortletRequest method to get the LiferayPortletRequest you need and avoid that class cast. You could use PortalUtil as it is used here ... calling getLiferayPortletRequest instead:
https://github.com/liferay/liferay-faces-portal/blob/master/demo/jsf-login-portlet/src/main/java/com/liferay/faces/demos/bean/LoginBackingBean.java#L80-L84

Hope that helps,
Vernon
Jan Tošovský, modificado hace 6 años.

RE: RenderRequestBridgeLiferayImpl cannot be cast to LiferayPortletRequest

Liferay Master Mensajes: 566 Fecha de incorporación: 22/07/10 Mensajes recientes
I agree that casting is suboptimal. It is a slightly modified version mentioned in this thread.

Ok, I'll use your approach PortalUtil.getLiferayPortletRequest(portletRequest) instead.

Btw, when Liferay Portal 6.2 + JSF 2.2 + JSF Standard combination is selected on liferayfaces.org, it returns the version 4.1.0 (com.liferay.faces.bridge.impl). So I preferred the most recent one available in the maven repo, which is 4.2.5-ga6. I am not aware of any new releases.

Jan
thumbnail
Vernon Singleton, modificado hace 6 años.

RE: RenderRequestBridgeLiferayImpl cannot be cast to LiferayPortletRequest

Expert Mensajes: 315 Fecha de incorporación: 14/01/13 Mensajes recientes
Hi Jan,

Jan TošovskýBtw, when Liferay Portal 6.2 + JSF 2.2 + JSF Standard combination is selected on liferayfaces.org, it returns the version 4.1.0 (com.liferay.faces.bridge.impl). So I preferred the most recent one available in the maven repo, which is 4.2.5-ga6. I am not aware of any new releases.

Wow ... I should not assume that everyone knows about the new Liferay Faces version scheme:
https://dev.liferay.com/develop/tutorials/-/knowledge_base/6-2/understanding-the-liferay-faces-version-scheme

Yes, you will notice that the new 4.1.0 jars from 2017 are actually newer than the old 4.2.5 jars which were released back in 2015. There were announcements and discussions about the new version scheme, but sometimes it is hard to reach everyone. Thank you for explaining your confusion. This will remind us to keep mentioning this.