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

发布于 2024-10-25 09:25:20 字数 3231 浏览 4 评论 0原文

我遇到了 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 上不起作用的任何可能原因?

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 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寻找我们的幸福 2024-11-01 09:25:20

这与 JSF 问题 1937 有关,该问题是由于在JSF impl,自 2.1.0 beta 9 起。但是它应该已经在 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。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文