开发者

JSF 2 setup issue in Tomcat 7 (java.lang.InstantiationException: com.sun.faces.application.ServletContextSensitiveSingletonStore)

开发者 https://www.devze.com 2023-02-18 22:58 出处:网络
I have an issue that keeps arising with JSF 2 and Tomcat 7.0.0. When I setup Apache MyFaces 2.0.4 (by putting all the jars in my WEB-INF/lib folder), Tomcat deploys my WAR file successfully.

I have an issue that keeps arising with JSF 2 and Tomcat 7.0.0. When I setup Apache MyFaces 2.0.4 (by putting all the jars in my WEB-INF/lib folder), Tomcat deploys my WAR file successfully.

However, when I setup JSF (Mojarra 2.1.0 - FCS) the same way as I do MyFaces, the following exception gets through (and this causes Tomcat to fail).

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开发者_Go百科 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)

I've done Google Searches but there are no valid solutions to fix this issue.

My web.xml is version 3.0 (although this is unecessary but I put it here in case someone asks).

Any possible reasons why this doesn't work on Tomcat?


This is related to JSF issue 1937 which was caused by accidently using Glassfish-specific code in the JSF impl, since 2.1.0 beta 9. It should however already be fixed in 2.1.0 FCS. I haven't tried it on Tomcat 7 yet, but it works for me on JBoss 6 (which uses a fork of Tomcat 7 under the covers). Alternatively, you can also use the latest 2.0, which is currently 2.0.4. It certainly works on Tomcat 6/7.


Update: I can reproduce this with 2.1.0 FCS on Tomcat 7.0.11:

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)

I'd kick issue 1937 and complain that it's still not fixed for Tomcat yet. In the meanwhile, you'd have to use Mojarra 2.0 instead.

0

精彩评论

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