user3845254
user3845254

Reputation: 61

Liferay issue: com.liferay.portlet.ResourceResponseImpl cannot be cast to javax.portlet.response

I'm working on liferay 6.2 GA2. when I try this

`RenderResponse renderRespons = (RenderResponse)   request.getAttribute("javax.portlet.response");` 

I got this error on console.

com.liferay.portlet.ResourceResponseImpl cannot be cast to javax.portlet.response

please help

Upvotes: 0

Views: 280

Answers (1)

Olaf Kock
Olaf Kock

Reputation: 48122

First of all: Wherever you have a HttpServletResponse, you probably also have a PortletResponse available - it feels weird to need to get it this way and you might want to redesign your architecture.

Next, almost always when you can't typecast to the obvious superclass (or interface) of a class/object, most likely you have one of the involved classes twice on the classpath, typically the superclass. In your case, it's probably the portlet.jar: Make sure it's not contained in your project's WEB-INF/lib directory, as it's already available on the global classpath.

Depending on where you actually do this, there's a chance that it might be another classloading issue: when your own plugin doesn't have access to the class definition for ResourceResponseImpl (it typically doesn't have this access), I'm not sure what error message to expect in this case.

Upvotes: 1

Related Questions