java.lang.ClassCastException:无法将javax.faces.component.StateHolderSaver强制转换为[Ljava.lang.Object;

编程入门 行业动态 更新时间:2024-10-27 00:25:09
本文介绍了java.lang.ClassCastException:无法将javax.facesponent.StateHolderSaver强制转换为[Ljava.lang.Object;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在xhtml页面中显示带有链接的项目列表.当我从该链接单击返回上一页"按钮时,我基本上会重置bean中的标志以向xhtml指示要显示的页面,然后从数据库中重新加载链接列表.

I am displaying a list of items with links in my xhtml page. When I click my "back to previous page" button from that link, I basically reset the flags in my bean to indicate to the xhtml which page to display, and reload the list of links from my database.

当我在这个新页面中单击相同的链接(或与此相关的任何其他链接)时,出现此错误:

When I click the same link (or any other link for that matter) in this new page, I get this error:

javax.portlet.faces.BridgeException: javax.portlet.faces.BridgeException: javax.faces.FacesException: Unexpected error restoring state for component with id A8351:j_idt7:j_idt10:j_idt59. Cause: java.lang.ClassCastException: javax.facesponent.StateHolderSaver cannot be cast to [Ljava.lang.Object;. at com.liferay.faces.bridge.BridgePhaseActionImpl.execute(BridgePhaseActionImpl.java:105) at com.liferay.faces.bridge.BridgeImpl.doFacesRequest(BridgeImpl.java:81) at javax.portlet.faces.GenericFacesPortlet.processAction(GenericFacesPortlet.java:152) at com.ncs.portalcity.lfe.faces.bridge.FacesPortlet.processAction(FacesPortlet.java:47) at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:70) at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:48) at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:111) at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) ... ... Caused by: javax.faces.FacesException: Unexpected error restoring state for component with id A8351:j_idt7:j_idt10:j_idt59. Cause: java.lang.ClassCastException: javax.facesponent.StateHolderSaver cannot be cast to [Ljava.lang.Object;. at com.sun.faces.application.view.StateManagementStrategyImpl$2.visit(StateManagementStrategyImpl.java:284) at com.sun.facesponent.visit.FullVisitContext.invokeVisitCallback(FullVisitContext.java:151) at javax.facesponent.UIComponent.visitTree(UIComponent.java:1589) at javax.facesponent.UIComponent.visitTree(UIComponent.java:1600) at javax.facesponent.UIComponent.visitTree(UIComponent.java:1600) at javax.facesponent.UIForm.visitTree(UIForm.java:344) at javax.facesponent.UIComponent.visitTree(UIComponent.java:1600) at javax.facesponent.UIComponent.visitTree(UIComponent.java:1600) at com.sun.faces.application.view.StateManagementStrategyImpl.restoreView(StateManagementStrategyImpl.java:263) at com.sun.faces.application.StateManagerImpl.restoreView(StateManagerImpl.java:188) at com.sun.faces.application.view.ViewHandlingStrategy.restoreView(ViewHandlingStrategy.java:123) at com.sun.faces.application.view.FaceletViewHandlingStrategy.restoreView(FaceletViewHandlingStrategy.java:452) at com.sun.faces.application.view.MultiViewHandler.restoreView(MultiViewHandler.java:148) at javax.faces.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:303) at com.liferay.faces.bridge.application.ViewHandlerImpl.restoreView(ViewHandlerImpl.java:88) at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:192) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) at com.liferay.faces.bridge.lifecycle.LifecycleWrapper.execute(LifecycleWrapper.java:35) at com.liferay.faces.bridge.BridgePhaseActionImpl.execute(BridgePhaseActionImpl.java:77) ... 142 more Caused by: java.lang.ClassCastException: javax.facesponent.StateHolderSaver cannot be cast to [Ljava.lang.Object; at javax.facesponent.behavior.AjaxBehavior.restoreState(AjaxBehavior.java:459) at javax.facesponent.UIComponentBase.restoreBehaviors(UIComponentBase.java:2184) at javax.facesponent.UIComponentBase.restoreBehaviorsState(UIComponentBase.java:2151) at javax.facesponent.UIComponentBase.restoreState(UIComponentBase.java:1571) at com.sun.faces.application.view.StateManagementStrategyImpl$2.visit(StateManagementStrategyImpl.java:276) ... 162 more

如果刷新页面并重试,则没有任何问题.有人知道我在做什么错吗?

If I refresh the page and try again, there are no issues. Does anyone have any idea what I'm doing wrong?

----编辑----

---- Edit ----

以防万一其他使用liferay的人遇到此问题,我只是在pom.xml中添加了以下几行,现在就可以了:)非常感谢BaluC!

Just in case anyone else using liferay has this problem, I just added these lines in my pom.xml and it's ok now :) Thanks so much BaluC!

<dependency> <groupId>com.sun.faces</groupId> <artifactId>jsf-api</artifactId> <version>2.1.21</version> <scope>compile</scope> </dependency> <dependency> <groupId>com.sun.faces</groupId> <artifactId>jsf-impl</artifactId> <version>2.1.21</version> <scope>compile</scope> </dependency>

推荐答案

这是一个已知的Mojarra问题,已报告为 issue 2041 ,已在Mojarra 2.1.12中修复.

This is a known Mojarra issue and already reported as issue 2041 which is fixed in Mojarra 2.1.12.

因此,只需将JSF库至少升级到Mojarra 2.1.12.目前已经是2.1.26,与2.1.12相比,还有更多与状态管理和喜欢相关的修复程序.

So, just upgrading your JSF libraries to at least Mojarra 2.1.12 should do. It's currently already at 2.1.26, with many more fixes related to state management and likes as compared to 2.1.12.

更多推荐

java.lang.ClassCastException:无法将javax.faces.component.StateHolderSaver强制转换为[Ljav

本文发布于:2023-10-31 05:16:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1545115.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:转换为   ClassCastException   javax   lang   java

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!