开发者

RichFaces4 startup fails with java.lang.IllegalArgumentException: duplicate key: class javax.faces.convert.DoubleConverter

This seems not be not a simple task with RichFaces4 without Maven, I download myfaces-2.0.9 jars and richfaces 4.0.0 and added sac-1.3.jar, guava-r08.jar and cssparser-0.9.5.jar.

The environment I am working is Tomcat 6.0, But I am unable to setup a simple richfaces4 based web application when ever I run tomcat I get different issues. I added few jars related to the below error but I get another duplicate key error for another converter,

On an other note: I also had to remove tomohawk from tomcat as I was using myfaces. Please help.

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.Application开发者_开发问答Impl._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)


This can happen if you also include the RichFaces source code JAR files in the classpath. They do not belong in the webapp's runtime classpath. It are the ones with a filename ending in -source.jar. You should remove them from the /WEB-INF/lib and put them if necessary somewhere else which do not end up in the webapp's runtime classpath.

The culprit is the csv.xml file which is present in /META-INF folder of both the richfaces-components-ui-4.0.0.Final.jar and richfaces-components-ui-4.0.0.Final-source.jar files. That file definies the standard converters and validators. However, because that file now appears twice in the classpath, it's been read twice, resulting in this duplicate key exception.


Unrelated to the concrete problem, removing Tomahawk because you're using MyFaces is a non-argument. The MyFaces JSF implementation does not contain the same components as Tomahawk. It's just another JSF implementation and technically the competitor of Mojarra. Tomahawk is a standalone component library which offers more enhanced components on top of the standard JSF implementation and can be used as good on top of every JSF implementation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜