IllegalArgumentException:重复键(JSF) [英] IllegalArgumentException: duplicate key (JSF)

查看:90
本文介绍了IllegalArgumentException:重复键(JSF)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Tomcat 7,Richfaces 4.2.2,MyFaces 2.1.5和Facelets.当我启动Tomcat时,出现错误:

I'm using Tomcat 7, Richfaces 4.2.2, MyFaces 2.1.5 and Facelets. When I start Tomcat I get the error:

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".

I saw the solution presented in this post, but different in this case, I don't have "-source.jar" in my classpath.

还有什么问题吗?

推荐答案

我和你是同一条船.

从链接到的帖子开始,我检查了WEB-INF/lib中的所有JAR文件,发现richfaces-components-ui-4.2.2.Final.jarrichfaces-ui-validator-ui-4.2.2.Final.jar都包含文件META-INF/csv.xml,该文件为该文件提供了映射.令人反感的课程(在我的情况下为IntegerConverter).

Taking off from the post you've linked to, I inspected all of my JAR files in WEB-INF/lib and found that both richfaces-components-ui-4.2.2.Final.jar and richfaces-ui-validator-ui-4.2.2.Final.jar contain a file META-INF/csv.xml which provides a mapping for the offending class (IntegerConverter, in my case).

我声明了以下Maven依赖项(前面列出了RichFaces 4.2.2Final BOM):

I had the following Maven dependencies declared (with the RichFaces 4.2.2Final BOM listed earlier):


<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-uirichfaces-ui-validator-ui的超集(即包含它和其他一些东西).

HOWEVER, the richfaces-components-ui is a super-set of richfaces-ui-validator-ui (that is, contains it and a few others).

您的配置/RichFaces组件可能有所不同,但答案取决于您的WEB-INF/lib目录中的内容(无论它是从Maven到达还是以其他方式到达)...您可能在其中包含了一个以上的JAR csv.xml文件.

Your configuration / RichFaces components may be different, but the answer lies in what's in your WEB-INF/lib directory (whether it got there from Maven or some other way)... you've likely included more than one JAR with a csv.xml file.

确定最少的依赖项集,错误就会消失.

Identify a minimal set of dependencies and the error will go away.

这篇关于IllegalArgumentException:重复键(JSF)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆