gpt4 book ai didi

java - Liferay portlet 部署 - 类转换异常

转载 作者:塔克拉玛干 更新时间:2023-11-02 18:59:46 25 4
gpt4 key购买 nike

我是 portlet 的新手,我正在尝试从我的 JSF 2.0 应用程序构建一个。我正在使用 liferay-portal-tomcat-6.1.0-ce-b4、JSF 2.1.3 和 PortletFaces 桥 2.0.1。

当我尝试将 portlet 安装到 liferay 中时,我总是遇到以下异常,我真的不知道为什么,因为根据文档,org.portletfaces.bridge.GenericFacesPortlet 应该实现 portlet 接口(interface)...

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>

关于java - Liferay portlet 部署 - 类转换异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8502254/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com