对于没有Maven的RichFaces4,这似乎不是一个简单的任务,我下载myfaces-2.0.9 jar和richfaces 4.0.0并添加了sac-1.3.jar,guava-r08.jar和cssparser-0.9.5.jar
我正在使用的环境是Tomcat 6.0,但是当我运行tomcat时,我无法设置一个简单的基于richfaces4的Web应用程序我遇到了不同的问题。我添加了几个与下面的错误相关的jar,但我得到了另一个转换器的另一个重复键错误
另一方面说明:当我使用myfaces时,我还必须从tomcat中删除tomohawk。请帮忙。
java.lang.IllegalArgumentException: duplicate key: class javax.faces.convert.DoubleConverter
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:115)
at com.google.common.collect.RegularImmutableMap.<init>(RegularImmutableMap.java:72)
at com.google.common.collect.ImmutableMap$Builder.fromEntryList(ImmutableMap.java:221)
at com.google.common.collect.ImmutableMap$Builder.build(ImmutableMap.java:207)
at org.richfaces.javascript.ClientServiceConfigParser.parseConfig(ClientServiceConfigParser.java:54)
at org.richfaces.application.ValidatorModule.createClientScriptService(ValidatorModule.java:68)
at org.richfaces.application.ValidatorModule.configure(ValidatorModule.java:62)
at org.richfaces.application.ServicesFactoryImpl.init(ServicesFactoryImpl.java:28)
at org.richfaces.application.InitializationListener.createFactory(InitializationListener.java:136)
at org.richfaces.application.InitializationListener.onStart(InitializationListener.java:110)
at org.richfaces.application.InitializationListener.processEvent(InitializationListener.java:152)
at javax.faces.event.SystemEvent.processListener(SystemEvent.java:43)
at org.apache.myfaces.application.ApplicationImpl._traverseListenerList(ApplicationImpl.java:2144)
at org.apache.myfaces.application.ApplicationImpl.access$000(ApplicationImpl.java:118)
at org.apache.myfaces.application.ApplicationImpl$SystemListenerEntry.publish(ApplicationImpl.java:2334)
at org.apache.myfaces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:554)
at org.apache.myfaces.webapp.AbstractFacesInitializer._dispatchApplicationEvent(AbstractFacesInitializer.java:254)
at org.apache.myfaces.webapp.AbstractFacesInitializer.initFaces(AbstractFacesInitializer.java:139)
at org.apache.myfaces.webapp.StartupServletContextListener.contextInitialized(StartupServletContextListener.java:111)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4172)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4671)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:701)
at org.apache.catalina.startup.Catalina.start(Catalina.java:585)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Oct 6, 2011 7:13:29 PM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
Oct 6, 2011 7:13:29 PM org.apache.catalina.core.StandardContext start
SEVERE: Context [/testRichFaces4] startup failed due to previous errors
Oct 6, 2011 7:13:29 PM org.apache.catalina.core.StandardContext listenerStop
SEVERE: Exception sending context destroyed event to listener instance of class org.apache.myfaces.webapp.StartupServletContextListener
java.lang.NullPointerException
at org.richfaces.application.CacheProvider.release(CacheProvider.java:86)
at org.richfaces.application.ServicesFactoryImpl.release(ServicesFactoryImpl.java:19)
at org.richfaces.application.ServiceTracker.release(ServiceTracker.java:100)
at org.richfaces.application.InitializationListener.onStop(InitializationListener.java:144)
at org.richfaces.application.InitializationListener.processEvent(InitializationListener.java:154)
at javax.faces.event.SystemEvent.processListener(SystemEvent.java:43)
at org.apache.myfaces.application.ApplicationImpl._traverseListenerList(ApplicationImpl.java:2144)
at org.apache.myfaces.application.ApplicationImpl.access$000(ApplicationImpl.java:118)
at org.apache.myfaces.application.ApplicationImpl$SystemListenerEntry.publish(ApplicationImpl.java:2334)
at org.apache.myfaces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:554)
at org.apache.myfaces.webapp.AbstractFacesInitializer._dispatchApplicationEvent(AbstractFacesInitializer.java:254)
at org.apache.myfaces.webapp.AbstractFacesInitializer.destroyFaces(AbstractFacesInitializer.java:285)
at org.apache.myfaces.webapp.StartupServletContextListener.contextDestroyed(StartupServletContextListener.java:153)
at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4211)
at org.apache.catalina.core.StandardContext.stop(StandardContext.java:4846)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4716)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:701)
at org.apache.catalina.startup.Catalina.start(Catalina.java:585)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Oct 6, 2011 7:13:29 PM com.sun.faces.config.ConfigureListener contextDestroyed
SEVERE: Unexpected exception when attempting to tear down the Mojarra runtime
java.lang.IllegalStateException: Application was not properly initialized at startup, could not find Factory: javax.faces.application.ApplicationFactory
at javax.faces.FactoryFinder$FactoryManager.getFactory(FactoryFinder.java:804)
at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:306)
at com.sun.faces.config.InitFacesContext.getApplication(InitFacesContext.java:108)
at com.sun.faces.config.ConfigureListener.contextDestroyed(ConfigureListener.java:327)
at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4211)
at org.apache.catalina.core.StandardContext.stop(StandardContext.java:4846)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4716)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:701)
at org.apache.catalina.startup.Catalina.start(Catalina.java:585)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
答案 0 :(得分:7)
如果您还在类路径中包含RichFaces 源代码 JAR文件,则会发生这种情况。它们不属于webapp的运行时类路径。它是文件名以-source.jar
结尾的文件名。你应该从/WEB-INF/lib
删除,并在必要时将它们放在其他不在webapp的运行时类路径中的地方。
罪魁祸首是csv.xml
文件,该文件存在于/META-INF
和richfaces-components-ui-4.0.0.Final.jar
文件的richfaces-components-ui-4.0.0.Final-source.jar
文件夹中。该文件定义标准转换器和验证器。但是,因为该文件现在在类路径中出现两次,所以它被读取了两次,导致这个重复的键异常。
无关到具体问题,因为你正在使用MyFaces而删除Tomahawk是一个非参数。 MyFaces JSF实现不包含与Tomahawk相同的组件。这只是另一个JSF实现,技术上是Mojarra的竞争对手。 Tomahawk是一个独立的组件库,它在标准JSF实现之上提供了更多增强的组件,并且可以在每个JSF实现之上使用。