1

我正在使用 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)

我看到了这篇文章中提出的解决方案,但在这种情况下有所不同,我的类路径中没有“-source.jar”。

还有什么可能是错的?

4

1 回答 1

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):

<依赖>
    <groupId>org.richfaces.ui</groupId>
    <artifactId>richfaces-components-ui</artifactId>
</依赖>
<依赖>
    <groupId>org.richfaces.core</groupId>
    <artifactId>richfaces-core-impl</artifactId>
</依赖>
<依赖>
    <groupId>org.richfaces.ui.validator</groupId>
    <artifactId>richfaces-ui-validator-ui</artifactId>
</依赖>

但是,它richfaces-components-ui是一个超集richfaces-ui-validator-ui(即包含它和其他一些)。

您的配置/RichFaces 组件可能不同,但答案在于您的目录中的内容(无论是从 Maven 还是以其他方式获得)……您可能在一个文件中WEB-INF/lib包含了多个 JAR 。csv.xml

确定一组最小的依赖项,错误就会消失。

于 2012-07-20T17:42:35.393 回答