留言板

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

VELMURUGAN SUBRAMANIAN,修改在13 年前。

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

New Member 帖子: 5 加入日期: 11-1-10 最近的帖子
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,修改在13 年前。

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

Liferay Legend 帖子: 2655 加入日期: 05-7-27 最近的帖子
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,修改在13 年前。

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

New Member 帖子: 5 加入日期: 11-1-10 最近的帖子
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,修改在13 年前。

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

Liferay Legend 帖子: 2655 加入日期: 05-7-27 最近的帖子
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,修改在12 年前。

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

Junior Member 帖子: 42 加入日期: 11-11-10 最近的帖子
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,修改在12 年前。

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

Liferay Legend 帖子: 2655 加入日期: 05-7-27 最近的帖子
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,修改在12 年前。

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

Junior Member 帖子: 42 加入日期: 11-11-10 最近的帖子
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,修改在11 年前。

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

New Member 帖子: 23 加入日期: 12-1-18 最近的帖子
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