Reputation: 61
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
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