我正在使用Tomcat 7,Richfaces 4.2.2,MyFaces 2.1.5和Facelets。当我启动Tomcat时,我收到错误:
An error occured while initializing MyFaces: duplicate key: class javax.faces.convert.BooleanConverter
java.lang.IllegalArgumentException: duplicate key: class javax.faces.convert.BooleanConverter
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:53)
at org.richfaces.application.ValidatorModule.createClientScriptService(ValidatorModule.java:65)
at org.richfaces.application.ValidatorModule.configure(ValidatorModule.java:60)
at org.richfaces.application.ServicesFactoryImpl.init(ServicesFactoryImpl.java:27)
at org.richfaces.application.InitializationListener.createFactory(InitializationListener.java:139)
at org.richfaces.application.InitializationListener.onStart(InitializationListener.java:112)
at org.richfaces.application.InitializationListener.processEvent(InitializationListener.java:157)
at javax.faces.event.SystemEvent.processListener(SystemEvent.java:43)
at org.apache.myfaces.application.ApplicationImpl._traverseListenerList(ApplicationImpl.java:2105)
at org.apache.myfaces.application.ApplicationImpl.access$000(ApplicationImpl.java:118)
at org.apache.myfaces.application.ApplicationImpl$SystemListenerEntry.publish(ApplicationImpl.java:2292)
at org.apache.myfaces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:537)
at org.apache.myfaces.webapp.AbstractFacesInitializer._dispatchApplicationEvent(AbstractFacesInitializer.java:248)
at org.apache.myfaces.webapp.AbstractFacesInitializer.initFaces(AbstractFacesInitializer.java:140)
at org.apache.myfaces.webapp.StartupServletContextListener.contextInitialized(StartupServletContextListener.java:111)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4765)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5260)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:866)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:842)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:958)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1599)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
我在this post中看到了解决方案,但在这种情况下不同,我的类路径中没有“-source.jar”。
还有什么可能是错的?
答案 0 :(得分:0)
我和你一样的船。
从您链接的帖子中取消,我检查了WEB-INF / lib中的所有JAR文件,发现richfaces-components-ui-4.2.2.Final.jar
和richfaces-ui-validator-ui-4.2.2.Final.jar
都包含文件META-INF/csv.xml
它提供了违规类的映射(在我的例子中为IntegerConverter
)。
我声明了以下Maven依赖项(前面列出了RichFaces 4.2.2Final BOM):
<dependency> <groupId>org.richfaces.ui</groupId> <artifactId>richfaces-components-ui</artifactId> </dependency> <dependency> <groupId>org.richfaces.core</groupId> <artifactId>richfaces-core-impl</artifactId> </dependency> <dependency> <groupId>org.richfaces.ui.validator</groupId> <artifactId>richfaces-ui-validator-ui</artifactId> </dependency>
但是,richfaces-components-ui
是richfaces-ui-validator-ui
的超集(即包含它和其他一些)。
您的配置/ RichFaces组件可能有所不同,但答案在于您的WEB-INF/lib
目录中的内容(无论是从Maven还是其他方式)......您可能包含多个JAR使用csv.xml
文件。
识别一组最小的依赖项,错误就会消失。