0

我是 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 -名称]/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]\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

更新

感谢下面的答案以及这个答案,我弄清楚了发生了什么。

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

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

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

4

1 回答 1

2

这是某些 google 库的依赖冲突,可能是guavagoogle collection。要修复它,您需要查看您的依赖关系树。当您使用 myeclipse 时,打开您的 pom.xml 文件并在下面的选项卡中选择依赖层次视图。然后搜索我告诉你的依赖项。可能会出现不同的问题:

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

看看这个相关的问题

于 2013-07-15T19:44:28.830 回答