一尘不染

从Tomcat 7迁移到8时的Jsf实现版本NullPointerException

tomcat

我当前正在使用JSF 2.2.7和Icefaces 4.0.0版本。我的项目在Tomcat 7上运行,但是在尝试使其在Tomcat
8上运行时遇到了麻烦。我遇到了空指针异常,因为icefaces代码中的方法似乎正在检查所用jsf的当前版本。这总是返回null并且我似乎没有设置jsf的正确实现。堆栈跟踪如下:

org.icefaces.impl.context.DOMPartialViewContext.renderState(DOMPartialViewContext.java:743)处org.icefaces.util.EnvUtils.isJSF22(EnvUtils.java:976)处的java.lang.NullPointerException
javax.faces.component.UIViewRoot.encodeChildren(UIViewRoot.java:1004)处的DOMPartialViewContext.processPartial(DOMPartialViewContext.java:301)在javax.faces.context.PartialViewContextWrapper.processPartial(PartialViewContextWrapper.java:219)在javax.faces.component
com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:430)上的.UIComponent.encodeAll(UIComponent.java:1856)在com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java)
:133),位于javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337),位于com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120),位于com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101),位于com.sun.faces.lifecycle.LifecycleImpl
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)的javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)的.render(LifecycleImpl.java:219)位于org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)的catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)处org.apache.catalina.core.StandardWrapperValve。在org.apache上的org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:614)上的org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)上的invoke(StandardWrapperValve.java:219)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)的.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java
:617)位于org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88),位于org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518),位于org.apache.coyote.http11。
org.apache.coyote.AbstractProtocol $
AbstractConnectionHandler上的AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)。org.apache.tomcat.util.net.NioEndpoint
$
SocketProcessor.doRun(NioEndpoint.java:1527)处的进程(AbstractProtocol.java:668)org.apache.tomcat.util.net.NioEndpoint
$
SocketProcessor.run(NioEndpoint。的java.util.concurrent.ThreadPoolExecutor.runWorker(java:1484)(java.util.concurrent.ThreadPoolExecutor
$ Worker.run(ThreadPoolExecutor.java:615)处org.apache.tomcat.util.threads
.TaskThread $ WrappingRunnable.run(TaskThread.java:61)at
java.lang.Thread.run(Thread.java:744)2015年8月4日上午7:50:52
com.sun.faces.application.view.FaceletViewHandlingStrategy
handleRenderException严重:错误呈现视图[/pages/Ports.xhtml]
org.icefaces.impl.context.DOMPartialViewContext上的org.icefaces.util.EnvUtils.isJSF22(EnvUtils.java:976)上的java.lang.NullPointerException。org.icefaces.impl.context.DOMPartialViewContext.processPartial(DOMPartialViewContext.java:301)的renderState(DOMPartialViewContext.java:743)在javax.faces.component的javax.faces.context.PartialViewContextWrapper.processPartial(PartialViewContextWrapper.java:219)
.UIViewRoot.encodeChildren(UIViewRoot.java:1004)位于com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:430)位于javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)
com.sun.faces.lifecycle.RenderResponsePhase.execute()上的javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)上的com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:133)
RenderResponsePhase.java:120)位于com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)在com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)在javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)上的org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)上的(ApplicationFilterChain.java:291)。
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)的apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve。
java:219),位于org.apache的org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)。org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)上的catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:614)在org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:
79)在org.apache.catalina.valves.AbstractAccessLogValve.java:617在org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)在org.apache.catalina.connector.CoyoteAdapter
.org上的.service(CoyoteAdapter.java:518)在org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)在org.apache.coyote.AbstractProtocol
$ AbstractConnectionHandler.process(AbstractProtocol.java:668)在org。
org.apache.tomcat.util.net上的apache.tomcat.util.net.NioEndpoint $
SocketProcessor.doRun(NioEndpoint.java:1527)。org上的java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)上的NioEndpoint
$
SocketProcessor.run(org.org.java:1145)在org上的java.util.concurrent.ThreadPoolExecutor
$ Worker.run(ThreadPoolExecutor.java:615)
.apache.tomcat.util.threads.TaskThread $
WrappingRunnable.run(TaskThread.java:61)at
java.lang.Thread.run(Thread.java:744)2015年8月4日,com.sun。
faces.context.AjaxExceptionHandlerImpl
handlePartialResponseError严重:org.icefaces.impl.context.DOMPartialViewContext.renderState(DOMPartialViewContext.java:743处的java.lang.NullPointerException在org.icefaces.util.EnvUtils.isJSF22(EnvUtils.java:976)
org.icefaces.impl.context.DOMPartialViewContext.processPartial(DOMPartialViewContext.java:301),位于javax.faces.context.PartialViewContextWrapper。com.sun.faces.application上javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)上的javax.faces.component.UIViewRoot.encodeChildren(UIViewRoot.java:1004)上的processPartial(PartialViewContextWrapper.java:219)
.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:430)在com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:133)在javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)
)的com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)的com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)的com.sun.faces.lifecycle.LifecycleImpl。
org.apache.catalina.core处的javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)处的render(LifecycleImpl.java:219)。org.apache.catalina.core上的ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)(位于org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)上的ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)在org.apache.catalina.core.StandardWrapperValve.invoke
(StandardWrapperValve.java:219)在org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)在org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:614)在org.apache。位于org.apache.catalina的catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)。org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)处的阀.ErrorReportValve.invoke(ErrorReportValve.java:79)在org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:617)在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)在org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)在org.apache.coyote.AbstractProtocol
$ AbstractConnectionHandler.process
(AbstractProtocol.java:668)在org.apache.tomcat.util.net.NioEndpoint $
SocketProcessor.doRun(NioEndpoint.java:1527)在org.apache.tomcat.util.net.NioEndpoint
$ SocketProcessor.run(NioEndpoint.java
:1484),位于java.util.concurrent,位于java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)。org.apache.tomcat.util.threads.TaskThread
$ WrappingRunnable.run(TaskThread.java:61)处的ThreadPoolExecutor $
Worker.run(ThreadPoolExecutor.java:615)在java.lang.Thread.run(Thread.java:744)

经过仔细检查,似乎getImplementationVersion()方法返回null:

/**
 * Determine whether the current JSF implementation is version 2.2
 * @return true if JSF implementation is 2.2
 */
public static boolean isJSF22() {
    return FacesContext.class.getPackage().getImplementationVersion().startsWith("2.2");
}

这是我的带有IceFaces和JSF依赖项的pom.xml。我不确定如何设置我的JSF实现。

    <?xml version="1.0"?>
     <project
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
        xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <modelVersion>4.0.0</modelVersion>
        <groupId>oag.com.reference</groupId>
        <artifactId>web</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <name>ReferenceDataWeb </name>
        <packaging>war</packaging>
        <description>Reference data web project.</description>


    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>
        <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.7.0.201403182114</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <destFile>${sonar.jacoco.reportPath}</destFile>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>org.icefaces</groupId>
            <artifactId>icefaces</artifactId>
            <version>4.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.icefaces</groupId>
            <artifactId>icefaces-ace</artifactId>
            <version>4.0.0</version>
        </dependency>

        <dependency>
            <groupId>org.icepush</groupId>
            <artifactId>icepush</artifactId>
            <version>4.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.icefaces</groupId>
            <artifactId>icefaces-compat</artifactId>
            <version>3.3.0</version>
            <type>pom</type>
        </dependency>

        <dependency>
            <groupId>com.oag.reference</groupId>
            <artifactId>business</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>

        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>3.7</version>
        </dependency>

        <dependency>
            <groupId>org.icefaces.ace-themes</groupId>
            <artifactId>ace-cupertino</artifactId>
            <version>4.0.0</version>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.0.1</version>
            <scope>provided</scope>
        </dependency>

    </dependencies>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.sun.faces</groupId>
                <artifactId>jsf-api</artifactId>
                <version>2.2.7</version>
            </dependency>
            <dependency>
                <groupId>com.sun.faces</groupId>
                <artifactId>jsf-impl</artifactId>
                <version>2.2.7</version>
            </dependency>
        </dependencies>

    </dependencyManagement>

 </project>

这是在我的war文件WEB-INF / lib文件夹中创建的jar文件的完整列表:

ace-cupertino-4.0.0.jar
激活-1.1.jar 业务-0.0.1 -SNAPSHOT.jar
common-0.0.1-SNAPSHOT.jar commons-beanutils-1.8.0.jar
commons-logging-1.1.jar数据库- 0.0.1-SNAPSHOT.jar
db2jcc4-1.0.0.jar
hamcrest-core-1.1.jar icefaces-4.0.0.jar icefaces-ace-4.0.0.jar
icepush-4.0.0.jar javax.faces-2.2。 7.jar jstl
-1.2.jar junit-4.9.jar
邮件-1.4.1.jar mockito-all-1.9.5.jar
poi-3.7.jar

查看javax.faces-2.2.7.jar和META-INF /
MANIFEST.MF的内部内容,我可以看到实现版本设置为2.2.7。所以我不知道在运行时被icefaces代码引用时实现版本如何为null。

有人可以帮忙吗?

谢谢-
有关更多信息,请访问:http :
//www.icesoft.org/JForum/posts/list/22974.page#80376


阅读 220

收藏
2020-06-16

共1个答案

一尘不染

这很可能是由于Mojarra
2.2.9中已根据问题3341修复了错误的上下文类加载器而导致的。

至少升级到Mojarra 2.2.9(当前最新为2.2.12)应该可以解决您的问题。

2020-06-16