com.sun.faces.config.InitFacesContext.cleanupInitMaps上的Nullpointer异常 [英] Nullpointer exception at com.sun.faces.config.InitFacesContext.cleanupInitMaps

查看:95
本文介绍了com.sun.faces.config.InitFacesContext.cleanupInitMaps上的Nullpointer异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法将我的war文件部署到tomcat服务器中.我最后遇到了以下异常.

I am not able to deploy my war file into tomcat server. I am ending up with the below exception.

 SEVERE: ContainerBase.addChild: start: 
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/BatchApp-1.0.0.M1]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:977)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1655)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
    at com.sun.faces.config.InitFacesContext.cleanupInitMaps(InitFacesContext.java:281)
    at com.sun.faces.config.InitFacesContext.<init>(InitFacesContext.java:107)
    at com.sun.faces.config.FacesInitializer.onStartup(FacesInitializer.java:115)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5280)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 11 more

May 11, 2013 5:28:05 PM org.apache.catalina.startup.HostConfig deployWAR
SEVERE: Error deploying web application archive C:\AppDev\Tomcat7.0\webapps\BatchApp-1.0.0.M1.war
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/BatchApp-1.0.0.M1]]
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:904)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:977)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1655)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

我进一步对其进行了调试,看起来就像下面的com.sun.faces.config.InitFacesContext中的@getInitContextServletContextMap()方法一样,我最终返回了空指针.

I further debugged it and looks like at the below code @getInitContextServletContextMap() method in com.sun.faces.config.InitFacesContext I am ending up with null pointer being returned.

 static Map getInitContextServletContextMap() {
    ConcurrentHashMap initContextServletContext = null;
    try {
        Field initContextMap = FacesContext.class.getDeclaredField("initContextServletContext");
        initContextMap.setAccessible(true);
        initContextServletContext = (ConcurrentHashMap)initContextMap.get(null);
    } catch (Exception e) {
        if (LOGGER.isLoggable(Level.FINEST)) {
            LOGGER.log(Level.FINEST, "Unable to get (init context, servlet context) map", e);
        }
    }
    return initContextServletContext;
}

很明显,服务器正在寻找"initContextServletContext",但是在哪里设置呢?

It is cleared that the server is looking for "initContextServletContext", but where to set this?

请让我知道如何解决此问题.

Please let me know how can I resolve this issue.

推荐答案

出现了完全相同的错误.这是一个依赖关系问题:我正在使用Oracle的JSF(2.2.1)实现,但是我的Maven依赖关系之一是拉入Apache MyFaces.

Had the exact same error. It was a dependency issue: I was using Oracle's implementation of JSF (2.2.1), but one of my Maven dependencies was pulling in Apache MyFaces.

发生的事情是,您显示的代码片段(来自Oracle实现)试图访问FacesContext的静态私有字段.但是类加载器已经加载了FacesContext的MyFaces实现,该实现没有该字段.因此是酒吧.

What happened is that the code snippet that you show, which is from the Oracle impelementation, tries to access a static private field of FacesContext. But the classloader has loaded the MyFaces implementation of FacesContext, which doesn't have that field. Therefore barf.

检查您的依赖项.我敢打赌,您会发现您拥有两种不同的JSF版本或两种不同的JSF实现.

Check your dependencies. I bet you will find that you've got two different versions or two different implementations of JSF.

这篇关于com.sun.faces.config.InitFacesContext.cleanupInitMaps上的Nullpointer异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆