简体   繁体   English

Liferay问题:com.liferay.portlet.ResourceResponseImpl无法转换为javax.portlet.response

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

I'm working on liferay 6.2 GA2. 我正在研究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 请帮忙

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. 首先:无论您在何处拥有HttpServletResponse ,都可能还有PortletResponse可用-感觉很奇怪,需要以这种方式获取它,并且您可能想重新设计架构。

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. 在您的情况下,可能是portlet.jar :确保它不包含在项目的WEB-INF / lib目录中,因为它已经在全局类路径中可用。

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. 根据您实际执行此操作的位置,有可能是另一个类加载问题:当您自己的插件无权访问ResourceResponseImpl的类定义(通常没有此访问权)时,我不确定在这种情况下会出现什么错误消息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM