为什么这个RichFaces演示项目不能在Maven支持的Myeclipse Web项目中工作



我是Java的新手,一直在学习一些教程,以熟悉一些框架和技术,如JSF、Spring和RichFaces。我正在使用MyEclipse作为我的IDE,并在http://www.ibm.com/developerworks/java/library/j-richfaces4/index.html.这个问题的其余部分围绕着上面链接中显示的RichFaces+JSF2演示项目展开。

现在,当我使用J2EE规范级别5.0或6.0在MyEclipse中创建一个新的web项目并导入演示项目文件时,我可以将演示项目部署到MyEclipse-tomcat,当我访问localhost:8080/[projectname]/index.jsf.时,它运行良好

但是,如果我创建一个新的web项目(规范级别),同时添加maven支持(标准或MyEclipse风格),并以类似的方式导入相同的演示项目文件,那么就我而言,我无法启动和运行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]AppDataLocalMyEclipseCommonbinarycom.sun.java.jdk.win32.x86_1.6.0.013bin;C:Users[username]AppDataLocalMyEclipseCommonpluginscom.genuitec.eclipse.easie.tomcat.myeclipse_9.0.0.me201211011550tomcatbin
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

更新

多亏了下面的答案,以及这个,我明白了发生了什么。

有maven支持的myeclipseweb项目的一个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演示项目已经包含了番石榴,根据下面的评论,番石榴实际上是谷歌收藏的更新版本。

此外,有时在对项目依赖项进行更改后,对web应用程序进行简单的重新加载/刷新是不够的。我不得不停止服务器,删除web应用程序,重新启动服务器,然后重新部署应用程序。也许这是Java或MyEclipse的标准做法,或者我正在进行的特定更改,但我没想到必须这样做。

多么痛苦啊!但这是一次学习经历。

这是一些谷歌库的依赖冲突,可能是番石榴谷歌收藏。要修复它,您需要查看依赖关系树。在使用myeclipses时,打开pom.xml文件,并在下面的选项卡中选择依赖层次结构视图。然后搜索我告诉你的依赖关系。可能存在不同的问题:

  • 您正在排除需要它的工件的依赖项
  • Maven正在解决与新谷歌依赖关系的冲突,但这种方法是旧方法,您正在使用的第三方库会使用它。在这种情况下,您应该尝试更新您的第三方库或降级您自己使用的库的版本
  • 对于某些工件,您包含了一个版本的API依赖项和其他版本的实现。在这种情况下,执行程序希望找到这个方法,但它在实现中不可用

看看这个相关的问题。

相关内容

  • 没有找到相关文章

最新更新