spring - Liferay 7.2- Spring MVC Portlet: java.lang.ClassCastException: class com.liferay.portletmvc4spring.ViewRendererServlet 部署时出现问题
问题描述
我实现了一个 Liferay 7.2 portletmvc4spring 模块,我遵循了本教程https://github.com/liferay/portletmvc4spring/blob/master/README.md但在将此 portlet 部署到 Lr7.2 实例时遇到了问题(我在 google 中搜索但我没有找到具体的解决方案)也许有人过去有同样的问题,也许可以帮助......
问题如下:
2020-01-06 20:36:43.468 错误 [fileinstall-/usr/share/porttail/liferay-portal-7.2.0-ga1/osgi/war][WebXMLDefinitionLoader:1130] baseLr7Portlet_1.0.0 [1148] una java.lang .ClassCastException:com.liferay.portletmvc4spring.ViewRendererServlet 类
java.lang.ClassCastException:com.liferay.portletmvc4spring.DispatcherPortlet 无法转换为 javax.portlet.Portlet
完整的跟踪如下:
2020-01-06 20:36:13.337 信息 [fileinstall-/usr/share/porttail/liferay-portal-7.2.0-ga1/osgi/war][BaseAutoDeployListener:43] 复制 /usr/share/peLr7Portlet 的 portlet。战争 2020-01-06 20:36:13.378 信息 [fileinstall-/usr/share/porttail/liferay-portal-7.2.0-ga1/osgi/war][BaseDeployer:877] 部署 baseLr7Portlet.war 警告:META-INF /MANIFEST.MF 将来修改。警告:未来修改 META-INF/maven/com.company.porttail/baseLr7Portlet/pom.properties。警告:未来修改 META-INF/maven/com.company.porttail/baseLr7Portlet/pom.xml。警告:WEB-INF/classes/ValidationMessages.properties 将来会被修改。警告:WEB-INF/classes/com/company/porttail/demo/applicant/ApplicantPortlet.class 将来会被修改。警告:WEB-INF/classes/com/company/porttail/demo/configuration/ContactConfiguration.class 以后修改。警告:WEB-INF/classes/com/company/porttail/demo/configuration/ContactLanguage.class 将来会修改。警告:WEB-INF/classes/com/company/porttail/demo/controller/DemandeContactController.class 将来会修改。警告:WEB-INF/classes/content/language.properties 将来会被修改。
警告:WEB-INF/classes/log4j.properties 将来会被修改。
警告:WEB-INF/lib/Pportlet-api-3.0.0.jar 将来会被修改。
警告:WEB-INF/lib/api-model-3.6.4.jar 以后会修改。
警告:WEB-INF/lib/cdi-api-1.2.jar 将来会修改。
警告:WEB-INF/lib/com.liferay.portletmvc4spring.framework-5.2.0.jar 以后会修改。警告:WEB-INF/lib/com.liferay.portletmvc4spring.security-5.2.0.jar 以后会修改。警告:WEB-INF/lib/javax.el-api-3.0.0.jar 将来会修改。警告:WEB-INF/lib/javax.interceptor-api-1.2.jar 以后会修改。警告:WEB-INF/lib/porttail-common-3.6.4.jar 以后会修改。
警告:WEB-INF/lib/portlet-servlet-adapter-3.1.0.jar 将来会修改。警告:WEB-INF/liferay-plugin-package.properties 将来会被修改。警告:WEB-INF/spring-context/portlet-application-context.xml 将来会被修改。警告:WEB-INF/spring-context/portlet/portlet1-context.xml 将来会被修改。警告:WEB-INF/classes/com 将来会被修改。警告:WEB-INF/classes/com/company 将来会被修改。警告:WEB-INF/classes/com/company/porttail/demo/configuration 将来会被修改。警告:WEB-INF/spring-context 将来会被修改。警告:将来会修改图像。2020-01-06 20:36:14.440 信息 [fileinstall-/usr/share/porttail/liferay-portal-7.2.0-ga1/osgi/war][BaseAutoDeployListener:50] /usr/share/porttail/llet 的 Portlet . 310] baseLr7Portlet 的 0 个 portlet 可供使用 2020-01-06 20:43:27.512 错误 [fileinstall-/usr/share/porttail/liferay-portal-7.2.0-ga1/osgi/war][WabBundleProcessor:229]灾难性初始化失败!由于以下原因关闭 baseLr7Portlet WAB: com.sun.proxy.$Proxy935.registerServlets(Unknown Source) at com.liferay.portal.osgi.web.wab.extender.internal.WabBundleProcessor.init 处的 null java.lang.reflect.UndeclaredThrowableException (WabBundleProcessor.java:222) 在 com.liferay.portal.osgi.web.wab.extender.internal.WebBundleDeployer._initWabBundle(WebBundleDeployer.java:179) 在 com.liferay.portal.osgi.web.wab.extender.internal .WebBundleDeployer.doStart(WebBundleDeployer.java:101) 在 com.liferay.portal.osgi.web.wab.extender.internal.WabFactory$WABExtension.start(WabFactory.java:
这是我的 Portlet.xml 文件:
<?xml version="1.0"?>
<portlet-app xmlns="http://xmlns.jcp.org/xml/ns/portlet"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/portlet http://xmlns.jcp.org/xml/ns/portlet/portlet-app_3_0.xsd"
version="3.0">
<portlet>
<portlet-name>springDisptachar</portlet-name>
<portlet-class>com.liferay.portletmvc4spring.DispatcherPortlet</portlet-class>
<init-param>
<name>contextConfigLocation</name>
<value>/WEB-INF/spring-context/portlet/portlet1-context.xml</value>
</init-param>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>view</portlet-mode>
<portlet-mode>edit</portlet-mode>
<portlet-mode>help</portlet-mode>
</supports>
<resource-bundle>content.language</resource-bundle>
<portlet-preferences>
<preference>
<name>datePattern</name>
<value>MM/dd/yyyy</value>
</preference>
<preference>
<name>recipientEmailAddress</name>
<value>email@test.fr</value>
</preference>
</portlet-preferences>
<security-role-ref>
<role-name>administrator</role-name>
</security-role-ref>
<security-role-ref>
<role-name>guest</role-name>
</security-role-ref>
<security-role-ref>
<role-name>power-user</role-name>
</security-role-ref>
<security-role-ref>
<role-name>user</role-name>
</security-role-ref>
</portlet>
<filter>
<filter-name>SpringSecurityPortletFilter</filter-name>
<filter-class>com.liferay.portletmvc4spring.security.SpringSecurityPortletFilter</filter-class>
<lifecycle>ACTION_PHASE</lifecycle>
<lifecycle>RENDER_PHASE</lifecycle>
<lifecycle>RESOURCE_PHASE</lifecycle>
</filter>
<filter-mapping>
<filter-name>SpringSecurityPortletFilter</filter-name>
<portlet-name>baseLr7Portlet</portlet-name>
</filter-mapping>
</portlet-app>
任何建议表示赞赏。非常感谢...问候
解决方案
为了解决此类问题,我发现从一个能够正确部署和运行的最小 portlet 项目开始很有帮助。例如,我建议您首先从原型生成一个 PortletMVC4Spring JSP 项目:
mvn archetype:generate \
-DarchetypeGroupId=com.liferay.portletmvc4spring.archetype \
-DarchetypeArtifactId=com.liferay.portletmvc4spring.archetype.form.jsp.portlet \
-DarchetypeVersion=5.2.0 \
-DgroupId=com.mycompany \
-DartifactId=com.mycompany.my.form.jsp.portlet
然后,逐步添加依赖项和/或功能,每次更改后重新部署,直到问题发生。
我注意到的一件事是您的 portlet WAR 在 WEB-INF/lib 中包含一些可能不应该存在的依赖项。例如:
- WEB-INF/lib/cdi-api-1.2.jar
- WEB-INF/lib/javax.el-api-3.0.0.jar
- WEB-INF/lib/javax.interceptor-api-1.2.jar
CDI API jar 尤其令人担忧,因为 CDI 和 Spring 几乎总是相互排斥的。
推荐阅读
- authentication - 如何将基本身份验证添加到 Mapbox 中 WMS 源的标头
- wiremock - Wiremock 没有模板化请求路径段
- macos - OSX:Chrome 无法连接到 .localhost-domains。拒绝连接
- python - 如何在 python 中通过请求获取代理?
- flutter - 意外的空值颤振
- python-3.x - python中按模块搜索路径顺序输入路径是什么意思?
- angular - Angular Material DateRangePicker 更改左上角日期格式
- php - 在 RouteCollection 中使用实体管理器
- css - mPDF -和操纵失败
- gherkin - 黄瓜 - 重复步骤