java-Liferay Portlet部署-类强制转换异常
作者:互联网
我是Portlet的新手,我正在尝试从我的JSF 2.0应用程序构建一个.我正在使用liferay-portal-tomcat-6.1.0-ce-b4,JSF 2.1.3和PortletFaces bridge 2.0.1.
当我尝试将portlet安装到liferay中时,我总是得到以下异常,我真的不知道为什么,因为根据文档,org.portletfaces.bridge.GenericFacesPortlet应该实现portlet接口.
09:31:31,709 ERROR [HotDeployUtil:114]
com.liferay.portal.kernel.deploy.hot.HotD eployException: Error
registering portlets for MondisVisualizer-1.3-SNAPSHOT
com.liferay.portal.kernel.deploy.hot.HotDeployException: Error
registering portl ets for MondisVisualizer-1.3-SNAPSHOT
at com.liferay.portal.kernel.deploy.hot.BaseHotDeployListener.throwHotDe
ployException(BaseHotDeployListener.java:46)
at com.liferay.portal.deploy.hot.PortletHotDeployListener.invokeDeploy(P
ortletHotDeployListener.java:117)
at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._doFireDeployEvent
(HotDeployUtil.java:111)
at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._fireDeployEvent(H
otDeployUtil.java:188)
at com.liferay.portal.kernel.deploy.hot.HotDeployUtil.fireDeployEvent(Ho
tDeployUtil.java:40)
at com.liferay.portal.kernel.servlet.PortletContextListener.doPortalInit
(PortletContextListener.java:101)
at com.liferay.portal.kernel.util.BasePortalLifecycle.portalInit(BasePor
talLifecycle.java:42)
at com.liferay.portal.kernel.util.PortalLifecycleUtil.register(PortalLif
ecycleUtil.java:61)
at com.liferay.portal.kernel.util.PortalLifecycleUtil.register(PortalLif
ecycleUtil.java:53)
at com.liferay.portal.kernel.util.BasePortalLifecycle.registerPortalLife
cycle(BasePortalLifecycle.java:50)
at com.liferay.portal.kernel.servlet.PortletContextListener.contextIniti
alized(PortletContextListener.java:55)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContex
t.java:4723)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:
5226)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:
5221)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
utor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:908)
at java.lang.Thread.run(Thread.java:619) Caused by: java.lang.ClassCastException: org.portletfaces.bridge.GenericFacesPor
tlet cannot be cast to javax.portlet.Portlet
at com.liferay.portlet.PortletBagFactory.create(PortletBagFactory.java:1
31)
at com.liferay.portal.deploy.hot.PortletHotDeployListener.initPortlet(Po
rtletHotDeployListener.java:603)
at com.liferay.portal.deploy.hot.PortletHotDeployListener.doInvokeDeploy
(PortletHotDeployListener.java:385)
at com.liferay.portal.deploy.hot.PortletHotDeployListener.invokeDeploy(P
ortletHotDeployListener.java:114)
… 17 more
portlet.xml:
<?xml version="1.0" encoding="UTF-8"?>
<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0"
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd">
<portlet>
<portlet-name>Visualizer</portlet-name>
<portlet-class>org.portletfaces.bridge.GenericFacesPortlet</portlet-class>
<init-param>
<name>javax.portlet.faces.defaultViewId.view</name>
<value>/index.xhtml</value>
</init-param>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>view</portlet-mode>
</supports>
<portlet-info>
<title>Mondis Visualizer</title>
</portlet-info>
</portlet>
</portlet-app>
liferay-portlet.xml:
<liferay-portlet-app>
<portlet>
<portlet-name>Visualizer</portlet-name>
<instanceable>true</instanceable>
<remoteable>false</remoteable>
<ajaxable>false</ajaxable>
<!-- <header-portlet-css>/resources/styles/bookCatalog.css</header-portlet-css>
<header-portlet-javascript>/resources/scripts/jsf.js</header-portlet-javascript> -->
</portlet>
</liferay-portlet-app>
liferay-display.xml:
<?xml version="1.0"?>
<!DOCTYPE display PUBLIC "-//Liferay//DTD Display 6.0.0//EN" "http://www.liferay.com/dtd/liferay-display_6_0_0.dtd">
<display>
<category name="category.mondis.visualizer">
<portlet id="Visualizer" />
</category>
</display>
提前致谢.
解决方法:
我发现了问题,这使我的Portlet终止了.
捆绑的liferay的porlet.jar可能会被黑客入侵/修改.解决方法是在maven中将portlet.jar依赖项设置为“提供”-Java将在运行时将您的代码链接到tomcat中的(可能已修改)库.它将起作用…
<dependency>
<groupId>javax.portlet</groupId>
<artifactId>portlet-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
标签:classcastexception,portlet,jsf-2,java 来源: https://codeday.me/bug/20191202/2084908.html