Fórum

ClassCastException: com.liferay.portlet.ResourceResponseImpl cannot be cast

VELMURUGAN SUBRAMANIAN, modificado 12 Anos atrás.

ClassCastException: com.liferay.portlet.ResourceResponseImpl cannot be cast

New Member Postagens: 5 Data de Entrada: 10/01/11 Postagens Recentes
Hi all,
I've used the below code to generate resource Url for PDF download link in my portlet.


<portlet:resourceurl id="myPDF" var="myRenderURL">
			<portlet:param name="ln" value="metricsPDFExport" />
			<portlet:param name="javax.faces.resource" value="export" />
		</portlet:resourceurl>

		<a href="#{myRenderURL}" target="_blank">Export PDF</a>


When the page renders for the first time, I cannot see any issues during the render phase of the portlet and as well as resource URL also generates very well. Even I'm able to download PDF file using the Url link generated during render phase while using custom Resource Handler class implementation which I followed, http://www.liferay.com/community/liferay-projects/liferay-faces/demos#jsf2-export-pdf-portlet.

But instead of generating the unique resource URL from the server side, I'm trying to generate from xhtml page as mentioned above.

In this case, all other events (ValueChangeListener, ActionListener,RowSelectListener etc) stopped working properly. These events are triggered as expected and after this render phase kicks in to reload the page where I'm getting the below exception.


14:43:43,296 DEBUG [ExternalContextImpl:899] request parameter _facesViewId=[/xhtml/portletViewMode.xhtml]
accountValueChangeListener() [newAccountNumber:45330]  [oldAccountNumber:null
14:43:43,359 DEBUG [PortletContainerImpl:39] createActionURL fromURL=[/performancemetricsportlet/xhtml/portletViewMode.xhtml]
14:43:43,359 DEBUG [PortletContainerImpl:39] createActionURL fromURL=[/performancemetricsportlet/xhtml/portletViewMode.xhtml]
14:43:43,359 DEBUG [PortletContainerImpl:39] createPartialActionURL fromURL=[/performancemetricsportlet/xhtml/portletViewMode.xhtml]
14:43:43,359 DEBUG [PortletContainerImpl:39] createResourceURL fromURL=[/performancemetricsportlet/xhtml/portletViewMode.xhtml]
java.lang.ClassCastException: com.liferay.portlet.ResourceResponseImpl cannot be cast to javax.portlet.RenderResponse
	at org.portletfaces.bridge.renderkit.portlet.ResourceURLRenderer.encodeEnd(ResourceURLRenderer.java:45)
	at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:879)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1655)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1651)
	at javax.faces.render.Renderer.encodeChildren(Renderer.java:164)
	at org.icefaces.impl.renderkit.RendererWrapper.encodeChildren(RendererWrapper.java:54)
	at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:849)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1648)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1651)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1651)


I'm using below jsf and portlet bridge versions in my portlet.

1. portletfaces-bridge-2.0.0-RC1.jar
2. jsf-api-2.0.4-b06.jar
3. jsf-impl-2.0.4-b06.jar

Please let me know what I'm doing wrong here?

Thanks
Velu
thumbnail
Neil Griffin, modificado 12 Anos atrás.

RE: ClassCastException: com.liferay.portlet.ResourceResponseImpl cannot be

Liferay Legend Postagens: 2655 Data de Entrada: 27/07/05 Postagens Recentes
Whoops, that's a bug in the bridge. Sorry about that -- it's fixed in the source repository now, and will appear in version 2.0.1 when released. See: http://issues.liferay.com/browse/FACES-234
VELMURUGAN SUBRAMANIAN, modificado 12 Anos atrás.

RE: ClassCastException: com.liferay.portlet.ResourceResponseImpl cannot be

New Member Postagens: 5 Data de Entrada: 10/01/11 Postagens Recentes
Thanks Neil, Checked out the fix from the source repository, packaged as jar file and added to application build path. Worked like a charm. emoticon

Though with the fix, I could not able to achieve what I'm looking for. Here is the thing I'm trying to download a pdf.

There is an ice faces form which contains few selection criterias built using icefaces component like drop down and radio button (html and pdf) and one generate report command button.

When the user select either report type (html/pdf), I've to validate the form first, and if validation succeeds, then need to populate JSF model bean.

From this newly populated bean, I generate PDF object and need to send it back to the user's browser.

Portlet faces pdf example explains the part of downloading the pdf by initiating the portlet life cycle as RESOURCE_PHASE. So, I could not able to decode your pdf export example on how to call validation phase, get the input stream object from my backing bean and write it to RESOURCE_PHASE response stream.

Your help on this matter will be highly appreciable.

Thanks
Velu
thumbnail
Neil Griffin, modificado 12 Anos atrás.

RE: ClassCastException: com.liferay.portlet.ResourceResponseImpl cannot be

Liferay Legend Postagens: 2655 Data de Entrada: 27/07/05 Postagens Recentes
With a UI like this that requires validation, I would recommend that you make the download link disabled="true" or rendered="false" until the validation passes.
thumbnail
Johann Kneringer, modificado 11 Anos atrás.

RE: ClassCastException: com.liferay.portlet.ResourceResponseImpl cannot be

Junior Member Postagens: 42 Data de Entrada: 10/11/11 Postagens Recentes
Hi Neil,

is this issue similar to this exception?


14:59:22,666 ERROR [IPCPhaseListener:57] com.liferay.portlet.ResourceResponseImpl cannot be cast to javax.portlet.StateAwareResponse
java.lang.ClassCastException: com.liferay.portlet.ResourceResponseImpl cannot be cast to javax.portlet.StateAwareResponse
at org.portletfaces.bridge.event.IPCPhaseListener.processOutgoingPublicRenderParameters(IPCPhaseListener.java:211)

Is it fixed in the current version of portletfaces-bridge?

regards,
Johann
thumbnail
Neil Griffin, modificado 11 Anos atrás.

RE: ClassCastException: com.liferay.portlet.ResourceResponseImpl cannot be

Liferay Legend Postagens: 2655 Data de Entrada: 27/07/05 Postagens Recentes
Hi Johann,

If you have time, please give Liferay Faces Bridge 3.0.0-BETA1 a test drive and let me know if you still run into the ClassCastException.

Thanks,

Neil
thumbnail
Johann Kneringer, modificado 11 Anos atrás.

RE: ClassCastException: com.liferay.portlet.ResourceResponseImpl cannot be

Junior Member Postagens: 42 Data de Entrada: 10/11/11 Postagens Recentes
Unfortunatly I cannot reproduce the problem on my developementserver (which is 6.2, because of issues with hot deployment in liferay IDE with version 6.1 GA).

On my liveserver there I run version 6.1 GA where this error is shown, so I guess the error is fixed in 6.2...

Thanks anyways...
thumbnail
Ashish Renapurkar, modificado 11 Anos atrás.

RE: ClassCastException: com.liferay.portlet.ResourceResponseImpl cannot be

New Member Postagens: 23 Data de Entrada: 18/01/12 Postagens Recentes
Neil Griffin:
Hi Johann,

If you have time, please give Liferay Faces Bridge 3.0.0-BETA1 a test drive and let me know if you still run into the ClassCastException.

Thanks,

Neil



Hello Neil,

Thanks for this update. It will solve my problem. Thanks againemoticon