SpringBeanFacesELResolver不能与tomcat el一起使用

时间:2017-08-04 16:18:36

标签: spring jsf-2.2 tomcat8

我创建了一个具有以下配置的项目:

faces-config.xml中

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">



<context-param>
    <param-name>com.sun.faces.expressionFactory</param-name>
    <param-value>com.sun.el.ExpressionFactoryImpl</param-value>
</context-param>

的web.xml

<dependency>
        <groupId>javax.el</groupId>
        <artifactId>el-api</artifactId>
        <version>2.2</version>
    </dependency>
    <dependency>
        <groupId>org.glassfish.web</groupId>
        <artifactId>el-impl</artifactId>
        <version>2.2</version>
    </dependency>

和pom.xml

@Component("userQuery")
@SpringViewScope
public class UserQuery implements Serializable
{
    private String test = "test";
    //getter, setter for test
}

UserQuery.java

#{userQuery} // this works, returns userquery object
#{userQuery.test} //throw null pointer exception

test.xhtml

    SEVERE: Error Rendering View[/test.xhtml]
javax.el.ELException: /test.xhtml: null
    at com.sun.faces.facelets.compiler.TextInstruction.write(TextInstruction.java:90)
    at com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:82)
    at com.sun.faces.facelets.compiler.UILeaf.encodeAll(UILeaf.java:207)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1899)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1899)
    at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:451)
    at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
    at org.ocpsoft.rewrite.faces.RewriteViewHandler.renderView(RewriteViewHandler.java:186)

Caused by: java.lang.NullPointerException
    at java.lang.Class.isAssignableFrom(Native Method)
    at java.beans.Introspector.isAssignable(Introspector.java:809)

例外:

 VaadinServletRequest vsRequest = (VaadinServletRequest) VaadinService.getCurrentRequest ();
 HttpServletRequest httpServletRequest = vsRequest.getHttpServletRequest ();

 VaadinServletResponse vsResponse = (VaadinServletResponse) VaadinService.getCurrentResponse ();
 HttpServletResponse httpServletResponse = vsResponse.getHttpServletResponse ();

PS:当我删除SpringBeanFacesELResolver并使用jsf @ManagedBean而不是@component#{userQuery.test}也可以,但我不想这样使用。

春天出了什么问题?

我正在使用tomcat 8.5.16

1 个答案:

答案 0 :(得分:0)

我将JDK 1.8_5升级到1.8.77,问题解决了。