1

我在 JBoss AS 7.1.1 上使用 PrimeFaces 3.4.2 和 Mojarra 2.1.7。

恢复视图时出现以下异常。

21:58:33,203 ERROR  (http--127.0.0.1-8080-7) java.lang.NullPointerException
21:58:36,687 ERROR [stderr] (http--127.0.0.1-8080-7) java.lang.IllegalArgumentException: null source
21:58:36,687 ERROR [stderr] (http--127.0.0.1-8080-7)    at java.util.EventObject.<init>(EventObject.java:38)
21:58:36,687 ERROR [stderr] (http--127.0.0.1-8080-7)    at javax.faces.event.SystemEvent.<init>(SystemEvent.java:71)
21:58:36,703 ERROR [stderr] (http--127.0.0.1-8080-7)    at javax.faces.event.ComponentSystemEvent.<init>(ComponentSystemEvent.java:73)
21:58:36,703 ERROR [stderr] (http--127.0.0.1-8080-7)    at javax.faces.event.PostRestoreStateEvent.<init>(PostRestoreStateEvent.java:73)
21:58:36,703 ERROR [stderr] (http--127.0.0.1-8080-7)    at com.sun.faces.lifecycle.RestoreViewPhase.deliverPostRestoreStateEvent(RestoreViewPhase.java:271)
21:58:36,703 ERROR [stderr] (http--127.0.0.1-8080-7)    at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:257)
21:58:36,703 ERROR [stderr] (http--127.0.0.1-8080-7)    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
21:58:36,718 ERROR [stderr] (http--127.0.0.1-8080-7)    at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116)
21:58:36,718 ERROR [stderr] (http--127.0.0.1-8080-7)    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
21:58:36,718 ERROR [stderr] (http--127.0.0.1-8080-7)    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
@Override
public boolean isPostback() {

    assertNotReleased();
    Boolean postback = (Boolean) this.getAttributes().get(POST_BACK_MARKER);
    if (postback == null) {
        RenderKit rk = this.getRenderKit();
        if (rk != null) {
            postback = rk.getResponseStateManager().isPostback(this);
        } else {
            // ViewRoot hasn't been set yet, so calculate the RK
            ViewHandler vh = this.getApplication().getViewHandler();
            String rkId = vh.calculateRenderKitId(this);
            postback = RenderKitUtils.getResponseStateManager(this, rkId)
                  .isPostback(this);
        }
        this.getAttributes().put(POST_BACK_MARKER, postback);
    }

    return postback;

}

public String calculateRenderKitId(FacesContext context) {

    Util.notNull("context", context);

    Map<String,String> requestParamMap = context.getExternalContext()
        .getRequestParameterMap();
    String result = requestParamMap.get(         // <--------- exception here !!!!!!
        ResponseStateManager.RENDER_KIT_ID_PARAM);

    if (result == null) {
        if (null ==
            (result = context.getApplication().getDefaultRenderKitId())) {
            result = RenderKitFactory.HTML_BASIC_RENDER_KIT;
        }
    }
    return result;
}

调用时发生异常isPostback(),调用calculateRenderKitId().

String result = requestParamMap.get( // <--------- exception here !!!!!!
    ResponseStateManager.RENDER_KIT_ID_PARAM);

requestParamMap不可访问。这是如何引起的,我该如何解决?

4

1 回答 1

3

您很可能会遇到请求参数限制。不幸的是,由于 JSF 中的异常处理,真正的异常被隐藏了。默认情况下,一个请求只能有 512 个参数,因此如果您提交大型列表,请求将触发未捕获的非法 ArgumentException,该异常将被忽略,并且您的请求将因无意义的空指针异常而失败。

尝试将此添加到您的 jboss Standalone.xml

 <system-properties>
     <property name="org.apache.tomcat.util.http.Parameters.MAX_COUNT" value="5000"/>
</system-properties>
于 2013-03-28T18:22:58.700 回答