从Tomcat 7迁移到8

时间:2015-08-05 09:13:00

标签: maven jsf tomcat icefaces tomcat8

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

  

java.lang.NullPointerException at   org.icefaces.util.EnvUtils.isJSF22(EnvUtils.java:976)at   org.icefaces.impl.context.DOMPartialViewContext.renderState(DOMPartialViewContext.java:743)     在   org.icefaces.impl.context.DOMPartialViewContext.processPartial(DOMPartialViewContext.java:301)     在   javax.faces.context.PartialViewContextWrapper.processPartial(PartialViewContextWrapper.java:219)     在   javax.faces.component.UIViewRoot.encodeChildren(UIViewRoot.java:1004)     在javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)     在   com.sun.faces.application.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)at   com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)     在javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)     在   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)     在   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)     在   org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)     在   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.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)     在   org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)     在   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.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.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)     在   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)Aug 04,2015 7:50:52 AM   com.sun.faces.application.view.FaceletViewHandlingStrategy   handleRenderException SEVERE:错误渲染   查看[/pages/Ports.xhtml] java.lang.NullPointerException at   org.icefaces.util.EnvUtils.isJSF22(EnvUtils.java:976)at   org.icefaces.impl.context.DOMPartialViewContext.renderState(DOMPartialViewContext.java:743)     在   org.icefaces.impl.context.DOMPartialViewContext.processPartial(DOMPartialViewContext.java:301)     在   javax.faces.context.PartialViewContextWrapper.processPartial(PartialViewContextWrapper.java:219)     在   javax.faces.component.UIViewRoot.encodeChildren(UIViewRoot.java:1004)     在javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)     在   com.sun.faces.application.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)at   com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)     在javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)     在   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)     在   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)     在   org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)     在   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.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)     在   org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)     在   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.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.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)     在   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)Aug 04,2015 7:50:52 AM   com.sun.faces.context.AjaxExceptionHandlerImpl   handlePartialResponseError SEVERE:java.lang.NullPointerException     在org.icefaces.util.EnvUtils.isJSF22(EnvUtils.java:976)at   org.icefaces.impl.context.DOMPartialViewContext.renderState(DOMPartialViewContext.java:743)     在   org.icefaces.impl.context.DOMPartialViewContext.processPartial(DOMPartialViewContext.java:301)     在   javax.faces.context.PartialViewContextWrapper.processPartial(PartialViewContextWrapper.java:219)     在   javax.faces.component.UIViewRoot.encodeChildren(UIViewRoot.java:1004)     在javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)     在   com.sun.faces.application.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)at   com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)     在javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)     在   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)     在   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)     在   org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)     在   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.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)     在   org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)     在   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.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.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)     在   java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:615)     在   org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run(TaskThread.java:61)     在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-库珀蒂诺-4.0.0.jar
   激活1.1.jar   企业0.0.1-SNAPSHOT.jar
  共0.0.1-SNAPSHOT.jar   公地的BeanUtils-1.8.0.jar
  共享记录-1.1.jar   数据库-0.0.1-SNAPSHOT.jar
  db2jcc4-1.0.0.jar
  hamcrest核-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

了解详情

1 个答案:

答案 0 :(得分:3)

这很可能是因为手上有错误的上下文类加载器导致错误导致的问题,根据issue 3341修复了Mojarra 2.2.9。

升级到至少Mojarra 2.2.9(目前最新版本为2.2.12)可以解决您的问题。