将简单的Portlet部署到Liferay-ClassCastException [英] Deploying a simple Portlet to Liferay - ClassCastException
问题描述
我正在将最基本的Portlet部署到Liferay:
I'm deploying the most basic Portlet possible to Liferay:
public class FirstPortlet extends GenericPortlet
{
@RenderMode(name="VIEW")
public void welcomeWelcome(RenderRequest request,
RenderResponse response) throws
PortletException, IOException
{
PrintWriter out = response.getWriter();
out.println ("This is a portlet, <em>within a Portal</em>");
}
}
在部署时,我收到ClassCastException:
On deployment, I'm getting a ClassCastException:
Caused by: java.lang.ClassCastException: FirstPortlet cannot be cast to javax.po
rtlet.Portlet
在Google搜索之后,似乎部署portlet.jar是一个错误-我确保我没有意外地这样做.
After Googling, it appears that deploying portlet.jar is a mistake - I've made sure I'm not accidentally doing this.
javax.portlet.Portlet由GenericPortlet实现,所有Portlet示例似乎都扩展了GenericPortlet,所以我认为可以.
javax.portlet.Portlet is implemented by GenericPortlet, and all Portlet examples seem to extend GenericPortlet so I assume that's ok.
任何人都可以帮忙吗?
推荐答案
javax.portlet.Portlet已实现 通过GenericPortlet,以及所有Portlet 例子似乎扩展了GenericPortlet 所以我认为没关系.
javax.portlet.Portlet is implemented by GenericPortlet, and all Portlet examples seem to extend GenericPortlet so I assume that's ok.
如果GenericPortlet
实现Portlet
,我的猜测是您遇到类加载器问题.该类在两个不同的类加载器中加载了两次,因此被认为是不同的.
If GenericPortlet
implements Portlet
, my guess is that you have a class loader issue. The class is loaded twice, in two different class loaders and are by consequence considered different.
在谷歌搜索后,似乎 部署portlet.jar是一个错误- 我确保我不会意外 这样做.
After Googling, it appears that deploying portlet.jar is a mistake - I've made sure I'm not accidentally doing this.
我仍然建议您仔细检查一下是否在某处两次加载了portlet.jar
(或另一个包含Portlet
的jar).可能的位置取决于您使用的容器(Tomcat?Glassfish?).
I would still suggest that you double check if you don't have portlet.jar
(or another jar which contains Portlet
) loaded twice somewhere. The possible locations depend on the container you are using (Tomcat? Glassfish? ).
这篇关于将简单的Portlet部署到Liferay-ClassCastException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!