Tomcat 7中的JSF 2安装问题(java.lang.InstantiationException:com.sun.faces.application.ServletContextSensitiveSingletonStore)

时间:2011-03-19 19:29:31

标签: java-ee jsf-2 myfaces tomcat7

我遇到了JSF 2和Tomcat 7.0.0不断出现的问题。当我设置Apache MyFaces 2.0.4(通过将所有jar放入我的WEB-INF/lib文件夹中)时,Tomcat成功部署了我的WAR文件。

但是,当我以与MyFaces相同的方式设置JSF(Mojarra 2.1.0 - FCS)时,会发生以下异常(这会导致Tomcat失败)。

java.lang.InstantiationException: com.sun.faces.application.ServletContextSensitiveSingletonStore
    at java.lang.Class.newInstance0(Class.java:340)
    at java.lang.Class.newInstance(Class.java:308)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:118)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4268)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4771)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:138)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:785)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:763)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:558)
    at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:674)
    at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:599)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:538)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1390)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:355)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89)
    at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:312)
    at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:292)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:998)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:772)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:138)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:990)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:275)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:138)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:424)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:138)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:648)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:138)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:576)
    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:415)

我已完成Google搜索,但没有有效的解决方案可以解决此问题。

我的web.xml是3.0版本(虽然这是不必要的,但我把它放在这里以防万一有人问)。

为什么这对Tomcat无效?

1 个答案:

答案 0 :(得分:2)

这与JSF issue 1937有关,这是因为自2.1.0 beta 9以来在JSF impl中意外使用Glassfish特定代码引起的。但是它应该已经在2.1.0 FCS中修复了。我还没有在Tomcat 7上尝试过,但它适用于JBoss 6(它使用Tomcat 7的一个分支)。或者,您也可以使用最新的2.0,目前为2.0.4。它肯定适用于Tomcat 6/7。


更新:我可以在Tomcat 7.0.11上使用2.1.0 FCS重现这一点:

SEVERE: Error configuring application listener of class com.sun.faces.application.ServletContextSensitiveSingletonStore
java.lang.InstantiationException: com.sun.faces.application.ServletContextSensitiveSingletonStore
    at java.lang.Class.newInstance0(Class.java:340)
    at java.lang.Class.newInstance(Class.java:308)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:119)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4618)
    at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5184)
    at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5179)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)

我会踢1937年的问题并抱怨说它还没有为Tomcat修复。与此同时,你必须使用Mojarra 2.0。