<t:panelnavigation2>导致javax.faces.FacesException:无法两次添加相同的组件

时间:2015-09-21 09:54:59

标签: jsf jsf-2 tomahawk

我在WildFly 8.2.0上使用Tomahawk20 1.1.14 for JSF 2.0。使用<t:panelNagivation2>时,会抛出以下异常:

javax.faces.FacesException: Cannot add the same component twice

这是如何引起的,我该如何解决? 这是堆栈跟踪:

Caused by: javax.faces.FacesException: Cannot add the same component twice: nav:panel-nav:nav_panel-nav_uinavmitem1
    at com.sun.faces.context.StateContext$DynamicAddRemoveListener.handleAddRemoveWithAutoPrune(StateContext.java:751) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.context.StateContext$DynamicAddRemoveListener.handleAdd(StateContext.java:678) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.context.StateContext$AddRemoveListener.processEvent(StateContext.java:352) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.context.StateContext$DynamicAddRemoveListener.processEvent(StateContext.java:568) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at javax.faces.event.SystemEvent.processListener(SystemEvent.java:108) [jboss-jsf-api_2.2_spec-2.2.8.jar:2.2.8]
    at javax.faces.event.ComponentSystemEvent.processListener(ComponentSystemEvent.java:118) [jboss-jsf-api_2.2_spec-2.2.8.jar:2.2.8]
    at com.sun.faces.application.ApplicationImpl.processListenersAccountingForAdds(ApplicationImpl.java:2239) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.application.ApplicationImpl.invokeViewListenersFor(ApplicationImpl.java:2057) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:292) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:247) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at org.jboss.as.jsf.injection.weld.ForwardingApplication.publishEvent(ForwardingApplication.java:299) [wildfly-jsf-injection-8.2.0.Final.jar:8.2.0.Final]
    at javax.faces.component.UIComponentBase.publishAfterViewEvents(UIComponentBase.java:2253) [jboss-jsf-api_2.2_spec-2.2.8.jar:2.2.8]
    at javax.faces.component.UIComponentBase.doPostAddProcessing(UIComponentBase.java:1934) [jboss-jsf-api_2.2_spec-2.2.8.jar:2.2.8]
    at javax.faces.component.UIComponentBase.setParent(UIComponentBase.java:447) [jboss-jsf-api_2.2_spec-2.2.8.jar:2.2.8]
    at org.apache.myfaces.custom.navmenu.htmlnavmenu.HtmlNavigationMenuRenderer.addUINavigationMenuItems(HtmlNavigationMenuRenderer.java:355) [tomahawk20-1.1.14.jar:1.1.14]
    at org.apache.myfaces.custom.navmenu.htmlnavmenu.HtmlNavigationMenuRenderer.preprocessNavigationItems(HtmlNavigationMenuRenderer.java:340) [tomahawk20-1.1.14.jar:1.1.14]
    at org.apache.myfaces.custom.navmenu.htmlnavmenu.HtmlNavigationMenuRenderer.encodeEnd(HtmlNavigationMenuRenderer.java:175) [tomahawk20-1.1.14.jar:1.1.14]
    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:919) [jboss-jsf-api_2.2_spec-2.2.8.jar:2.2.8]
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863) [jboss-jsf-api_2.2_spec-2.2.8.jar:2.2.8]
    at javax.faces.render.Renderer.encodeChildren(Renderer.java:176) [jboss-jsf-api_2.2_spec-2.2.8.jar:2.2.8]
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:889) [jboss-jsf-api_2.2_spec-2.2.8.jar:2.2.8]
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856) [jboss-jsf-api_2.2_spec-2.2.8.jar:2.2.8]
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859) [jboss-jsf-api_2.2_spec-2.2.8.jar:2.2.8]
    at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:456) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:133) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337) [jboss-jsf-api_2.2_spec-2.2.8.jar:2.2.8]
    at org.apache.myfaces.tomahawk.application.ResourceViewHandlerWrapper.renderView(ResourceViewHandlerWrapper.java:169) [tomahawk20-1.1.14.jar:1.1.14]
    at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337) [jboss-jsf-api_2.2_spec-2.2.8.jar:2.2.8]
    at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337) [jboss-jsf-api_2.2_spec-2.2.8.jar:2.2.8]
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:647) [jboss-jsf-api_2.2_spec-2.2.8.jar:2.2.8]
    ... 20 more

将Wildfly降级为使用JSF 2.1.29-04(这是最新的2.1.x版本)会引发以下错误:

Caused by: java.lang.ClassNotFoundException: javax.faces.view.ViewScoped from [Module "org.jboss.as.jsf:main" from local module loader @15b3e5b (finder: local module finder @61ca2dfa (roots: /wildfly_8.2.0_final_acd/wildfly_8.2.0_final_acd/modules,/wildfly_8.2.0_final_acd/wildfly_8.2.0_final_acd/modules/system/layers/base))]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:408)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134)
... 24 more

实际上是班级

javax.faces.view.ViewScoped
jsf-api.jar

中缺少

1 个答案:

答案 0 :(得分:0)

JSF 2.0的Tomahawk与JSF 2.2不完全兼容。某些组件可能有效,但其他组件可能无效。 <t:panelNavigation2>就是这样的。您遇到的例外是动态组件树操作中的错误(之前用于解决编程组件树更改中的旧JSF 1.x错误)。

您有两个选择:

  1. 降级为JSF 2.1 / 2.0。您可以使用与此处所述相同的说明:Upgrade JSF / Mojarra in JBoss AS / EAP / WildFly您显然只会错过JSF 2.2特定功能。

  2. 或者,放下战斧。 MyFaces停止了Tomahawk的开发(至少,它已经不再维护多年了)。许多实用程序/增强功能已经在标准JSF中接管。对于可视化组件,请查找另一个UI组件库,例如PrimeFaces,或者只使用&#34; plain vanilla&#34; HTML / CSS(如果你不认为IE6 / 7是支持的浏览器,那么使用<ul><li>和一些CSS的菜单相对简单。)