我是Java的新手,并且一直在学习一些教程,以熟悉一些框架和技术,如JSF,Spring和RichFaces。我使用MyEclipse作为我的IDE,在http://www.ibm.com/developerworks/java/library/j-richfaces4/index.html找到了关于RichFaces + JSF2的非常好的文章。本问题的其余部分围绕上面链接中显示的RichFaces + JSF2演示项目。
现在,当我使用J2EE规范级别5.0或6.0在MyEclipse中创建一个新的Web项目并导入演示项目文件时,我可以将演示项目部署到myeclipse tomcat,当我访问localhost时它可以正常工作:8080 /[project-name]/index.jsf。
但是,如果我创建一个新的Web项目(规范级别)并添加maven支持(标准或MyEclipse样式),并以类似的方式导入相同的演示项目文件,对于我的生活,我可以& #39;启动并运行Web应用程序。我使用与上面相同的localhost URL(并引用新项目)。部署错误输出如下所示。
我错过了什么?
Jul 15, 2013 1:13:31 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Users\[username]\AppData\Local\MyEclipse\Common\binary\com.sun.java.jdk.win32.x86_1.6.0.013\bin;C:\Users\[username]\AppData\Local\MyEclipse\Common\plugins\com.genuitec.eclipse.easie.tomcat.myeclipse_9.0.0.me201211011550\tomcat\bin
Jul 15, 2013 1:13:31 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Jul 15, 2013 1:13:31 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 333 ms
Jul 15, 2013 1:13:31 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Jul 15, 2013 1:13:31 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.13
Jul 15, 2013 1:13:32 PM com.sun.faces.config.ConfigureListener contextInitialized
INFO: Initializing Mojarra 2.1.3 (FCS 20110908) for context '/rf4jee6stdmvn'
Jul 15, 2013 1:13:51 PM com.sun.faces.config.ConfigureListener contextInitialized
SEVERE: Critical error during deployment:
java.lang.NoSuchMethodError: com.google.common.base.Platform.precomputeCharMatcher(Lcom/google/common/base/CharMatcher;)Lcom/google/common/base/CharMatcher;
at com.google.common.base.CharMatcher.precomputed(CharMatcher.java:664)
at com.google.common.base.CharMatcher.<clinit>(CharMatcher.java:71)
at com.google.common.base.Splitter.on(Splitter.java:127)
at org.richfaces.resource.ResourceLibraryFactoryImpl.<clinit>(ResourceLibraryFactoryImpl.java:43)
at org.richfaces.application.DefaultModule.configure(DefaultModule.java:32)
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:106)
at com.sun.faces.application.ApplicationImpl.processListeners(ApplicationImpl.java:2139)
at com.sun.faces.application.ApplicationImpl.invokeListenersFor(ApplicationImpl.java:2115)
at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:300)
at com.sun.faces.config.ConfigManager.publishPostConfigEvent(ConfigManager.java:600)
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:369)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:225)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3827)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4334)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Jul 15, 2013 1:13:51 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class com.sun.faces.config.ConfigureListener
java.lang.RuntimeException: java.lang.NoSuchMethodError: com.google.common.base.Platform.precomputeCharMatcher(Lcom/google/common/base/CharMatcher;)Lcom/google/common/base/CharMatcher;
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:292)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3827)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4334)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: java.lang.NoSuchMethodError: com.google.common.base.Platform.precomputeCharMatcher(Lcom/google/common/base/CharMatcher;)Lcom/google/common/base/CharMatcher;
at com.google.common.base.CharMatcher.precomputed(CharMatcher.java:664)
at com.google.common.base.CharMatcher.<clinit>(CharMatcher.java:71)
at com.google.common.base.Splitter.on(Splitter.java:127)
at org.richfaces.resource.ResourceLibraryFactoryImpl.<clinit>(ResourceLibraryFactoryImpl.java:43)
at org.richfaces.application.DefaultModule.configure(DefaultModule.java:32)
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:106)
at com.sun.faces.application.ApplicationImpl.processListeners(ApplicationImpl.java:2139)
at com.sun.faces.application.ApplicationImpl.invokeListenersFor(ApplicationImpl.java:2115)
at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:300)
at com.sun.faces.config.ConfigManager.publishPostConfigEvent(ConfigManager.java:600)
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:369)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:225)
... 24 more
Jul 15, 2013 1:13:51 PM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
Jul 15, 2013 1:13:51 PM org.apache.catalina.core.StandardContext start
SEVERE: Context [/rf4jee6stdmvn] startup failed due to previous errors
Jul 15, 2013 1:13:51 PM com.sun.faces.lifecycle.ELResolverInitPhaseListener populateFacesELResolverForJsp
INFO: JSF1027: [null] The ELResolvers for JSF were not registered with the JSP container.
Jul 15, 2013 1:13:51 PM com.sun.faces.config.ConfigureListener contextDestroyed
SEVERE: Unexpected exception when attempting to tear down the Mojarra runtime
java.lang.NullPointerException
at org.richfaces.application.CacheProvider.release(CacheProvider.java:96)
at org.richfaces.application.ServicesFactoryImpl.release(ServicesFactoryImpl.java:18)
at org.richfaces.application.ServiceTracker.release(ServiceTracker.java:132)
at org.richfaces.application.InitializationListener.onStop(InitializationListener.java:147)
at org.richfaces.application.InitializationListener.processEvent(InitializationListener.java:159)
at javax.faces.event.SystemEvent.processListener(SystemEvent.java:106)
at com.sun.faces.application.ApplicationImpl.processListeners(ApplicationImpl.java:2139)
at com.sun.faces.application.ApplicationImpl.invokeListenersFor(ApplicationImpl.java:2115)
at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:300)
at com.sun.faces.config.ConfigureListener.contextDestroyed(ConfigureListener.java:332)
at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:3866)
at org.apache.catalina.core.StandardContext.stop(StandardContext.java:4500)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4364)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Jul 15, 2013 1:13:52 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Jul 15, 2013 1:13:52 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Jul 15, 2013 1:13:52 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/15 config=null
Jul 15, 2013 1:13:52 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 20428 ms
更新
感谢下面的答案,以及this one,我知道发生了什么。
mae支持的myeclipse web项目的maven依赖项之一导致了这个问题。所以我为那个特定的jar创建了一个排除。
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-osgi-bundle</artifactId>
<version>1.0.1-SP3</version>
<exclusions>
<exclusion>
<artifactId>google-collections</artifactId>
<groupId>com.google.collections</groupId>
</exclusion>
</exclusions>
</dependency>
这是有效的原因是因为richfaces演示项目已经包含guava,根据this answer下面的评论,它实际上是google-collections的新版本。
另外,有时在对项目依赖项进行更改后,Web应用程序的简单重新加载/刷新 不足以推出更改。我不得不停止服务器,删除Web应用程序,重新启动服务器,然后重新部署应用程序。也许这是Java或MyEclipse的标准做法或我正在进行的具体更改,但我没想到必须这样做。
多么痛苦啊!但这是一次学习经历。答案 0 :(得分:2)
这是一些谷歌图书馆的依赖冲突,可能是 guava 或 google collection 。要修复它,您需要查看依赖树。当您使用myeclipse时,打开您的pom.xml文件,然后在下面的选项卡中选择依赖关系层次结构视图。然后搜索我告诉你的依赖项。可能存在不同的问题: