Primefaces 10 dataTable p:dataExporter 在迁移后渲染时生成 ArrayIndexOutOfBoundsException

Primefaces 10 dataTable p:dataExporter generate ArrayIndexOutOfBoundsException on render after migration

环境:

我已经从 primefaces 8 迁移到 primefaces 10 dataTable p:dataExporter 在渲染 xhtml 时生成 ArrayIndexOutOfBoundsException。 当我注释掉 dataexporter 时,xhtml 呈现良好。

migration guide 之后,唯一重要的变化似乎是 PDF 库已从 iText 切换到 Libre OpenPDF。

我尝试了两种不同的上下文,一种有效,一种无效,差异:

我认为这与 primefaces 主题无关,但这可能是因为 keycloak,因为它在日志错误中显示处理请求。

出现此错误的原因是什么?

服务器错误

[161.883s][info][class,load] jdk.internal.reflect.GeneratedConstructorAccessor159 source: __JVM_DefineClass__
[161.885s][info][class,load] jdk.internal.reflect.GeneratedConstructorAccessor160 source: __JVM_DefineClass__
[161.886s][info][class,load] javax.faces.event.ExceptionQueuedEventContext source: jar:file:/C:/desarrollo/servers/jboss-eap-7.2/modules/system/layers/base/javax/faces/api/main/jboss-jsf-api_2.3_spec-2.3.5.SP1-redhat-1.jar!/
[161.887s][info][class,load] org.primefaces.application.exceptionhandler.ExceptionInfo source: vfs:/C:/desarrollo/workspace/accfor2/accfor/accfor-ear/target/accfor2/accfor-back.war/WEB-INF/lib/primefaces-10.0.0.jar
[161.887s][info][class,load] java.lang.Throwable$WrappedPrintWriter source: jrt:/java.base
15:25:43,304 SEVERE [org.primefaces.application.exceptionhandler.PrimeExceptionHandler] (default task-1) Index 15 out of bounds for length 15: java.lang.ArrayIndexOutOfBoundsException: Index 15 out of bounds for length 15
    at javax.faces.api@2.3.5.SP1-redhat-1//javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1439)
    at javax.faces.api@2.3.5.SP1-redhat-1//javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1460)
    at javax.faces.api@2.3.5.SP1-redhat-1//javax.faces.component.UIViewRoot.processRestoreState(UIViewRoot.java:955)
    at com.sun.jsf-impl@2.3.5.SP2-redhat-00001//com.sun.faces.application.view.JspStateManagementStrategy.restoreView(JspStateManagementStrategy.java:273)
    at com.sun.jsf-impl@2.3.5.SP2-redhat-00001//com.sun.faces.application.StateManagerImpl.restoreView(StateManagerImpl.java:139)
    at com.sun.jsf-impl@2.3.5.SP2-redhat-00001//com.sun.faces.application.view.ViewHandlingStrategy.restoreView(ViewHandlingStrategy.java:123)
    at com.sun.jsf-impl@2.3.5.SP2-redhat-00001//com.sun.faces.application.view.FaceletViewHandlingStrategy.restoreView(FaceletViewHandlingStrategy.java:295)
    at com.sun.jsf-impl@2.3.5.SP2-redhat-00001//com.sun.faces.application.view.MultiViewHandler.restoreView(MultiViewHandler.java:157)
    at javax.faces.api@2.3.5.SP1-redhat-1//javax.faces.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:125)
    at javax.faces.api@2.3.5.SP1-redhat-1//javax.faces.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:125)
    at com.sun.jsf-impl@2.3.5.SP2-redhat-00001//com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:204)
    at com.sun.jsf-impl@2.3.5.SP2-redhat-00001//com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
    at com.sun.jsf-impl@2.3.5.SP2-redhat-00001//com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:133)
    at com.sun.jsf-impl@2.3.5.SP2-redhat-00001//com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:201)
    at javax.faces.api@2.3.5.SP1-redhat-1//javax.faces.webapp.FacesServlet.service(FacesServlet.java:670)
    at io.undertow.servlet@2.0.15.Final-redhat-00001//io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)
    at io.undertow.servlet@2.0.15.Final-redhat-00001//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)
    at deployment.accfor2.ear.accfor-back.war//es.caib.accfor.presentation.back.security.UserPrincipalManager.doFilter(UserPrincipalManager.java:83)
    at io.undertow.servlet@2.0.15.Final-redhat-00001//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
    at io.undertow.servlet@2.0.15.Final-redhat-00001//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
    at deployment.accfor2.ear//es.caib.accfor.commons.administracio.boundary.ThemeFilter.doFilter(ThemeFilter.java:59)
    at io.undertow.servlet@2.0.15.Final-redhat-00001//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
    at io.undertow.servlet@2.0.15.Final-redhat-00001//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
    at deployment.accfor2.ear.accfor-ejb.jar//es.caib.accfor.business.logging.boundary.TimeLog.doFilter(TimeLog.java:54)
    at io.undertow.servlet@2.0.15.Final-redhat-00001//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
    at io.undertow.servlet@2.0.15.Final-redhat-00001//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
    at deployment.accfor2.ear.accfor-ejb.jar//es.caib.accfor.business.encoding.boundary.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:20)
    at io.undertow.servlet@2.0.15.Final-redhat-00001//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
    at io.undertow.servlet@2.0.15.Final-redhat-00001//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
    at io.opentracing.contrib.opentracing-jaxrs2@0.1.7.redhat-00001//io.opentracing.contrib.jaxrs2.server.SpanFinishingFilter.doFilter(SpanFinishingFilter.java:55)
    at io.undertow.servlet@2.0.15.Final-redhat-00001//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
    at io.undertow.servlet@2.0.15.Final-redhat-00001//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
    at io.undertow.servlet@2.0.15.Final-redhat-00001//io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
    at io.undertow.servlet@2.0.15.Final-redhat-00001//io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
    at io.undertow.servlet@2.0.15.Final-redhat-00001//io.undertow.servlet.handlers.ServletChain.handleRequest(ServletChain.java:68)
    at io.undertow.servlet@2.0.15.Final-redhat-00001//io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
    at org.wildfly.extension.undertow@7.2.0.GA-redhat-00005//org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
    at io.undertow.core@2.0.15.Final-redhat-00001//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at org.keycloak.keycloak-undertow-adapter@11.0.2//org.keycloak.adapters.undertow.UndertowAuthenticatedActionsHandler.handleRequest(UndertowAuthenticatedActionsHandler.java:66)
    at io.undertow.servlet@2.0.15.Final-redhat-00001//io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132)
    at io.undertow.servlet@2.0.15.Final-redhat-00001//io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
    at io.undertow.core@2.0.15.Final-redhat-00001//io.undertow.server.handlers.DisableCacheHandler.handleRequest(DisableCacheHandler.java:33)
    at io.undertow.core@2.0.15.Final-redhat-00001//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.core@2.0.15.Final-redhat-00001//io.undertow.security.handlers.AuthenticationConstraintHandler.handleRequest(AuthenticationConstraintHandler.java:53)
    at io.undertow.core@2.0.15.Final-redhat-00001//io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
    at io.undertow.servlet@2.0.15.Final-redhat-00001//io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
    at io.undertow.servlet@2.0.15.Final-redhat-00001//io.undertow.servlet.handlers.security.ServletSecurityConstraintHandler.handleRequest(ServletSecurityConstraintHandler.java:59)
    at io.undertow.core@2.0.15.Final-redhat-00001//io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
    at io.undertow.servlet@2.0.15.Final-redhat-00001//io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
    at io.undertow.core@2.0.15.Final-redhat-00001//io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
    at io.undertow.core@2.0.15.Final-redhat-00001//io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
    at io.undertow.core@2.0.15.Final-redhat-00001//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at org.wildfly.extension.undertow@7.2.0.GA-redhat-00005//org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
    at io.undertow.core@2.0.15.Final-redhat-00001//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at org.wildfly.extension.undertow@7.2.0.GA-redhat-00005//org.wildfly.extension.undertow.deployment.GlobalRequestControllerHandler.handleRequest(GlobalRequestControllerHandler.java:68)
    at org.keycloak.keycloak-undertow-adapter@11.0.2//org.keycloak.adapters.undertow.ServletPreAuthActionsHandler.handleRequest(ServletPreAuthActionsHandler.java:69)
    at io.undertow.core@2.0.15.Final-redhat-00001//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.servlet@2.0.15.Final-redhat-00001//io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)
    at io.undertow.servlet@2.0.15.Final-redhat-00001//io.undertow.servlet.handlers.ServletInitialHandler.access0(ServletInitialHandler.java:81)
    at io.undertow.servlet@2.0.15.Final-redhat-00001//io.undertow.servlet.handlers.ServletInitialHandler.call(ServletInitialHandler.java:138)
    at io.undertow.servlet@2.0.15.Final-redhat-00001//io.undertow.servlet.handlers.ServletInitialHandler.call(ServletInitialHandler.java:135)
    at io.undertow.servlet@2.0.15.Final-redhat-00001//io.undertow.servlet.core.ServletRequestContextThreadSetupAction.call(ServletRequestContextThreadSetupAction.java:48)
    at io.undertow.servlet@2.0.15.Final-redhat-00001//io.undertow.servlet.core.ContextClassLoaderSetupAction.call(ContextClassLoaderSetupAction.java:43)
    at org.wildfly.extension.undertow@7.2.0.GA-redhat-00005//org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create[=11=](SecurityContextThreadSetupAction.java:105)
    at org.wildfly.extension.undertow@7.2.0.GA-redhat-00005//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create[=11=](UndertowDeploymentInfoService.java:1502)
    at org.wildfly.extension.undertow@7.2.0.GA-redhat-00005//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create[=11=](UndertowDeploymentInfoService.java:1502)
    at org.wildfly.extension.undertow@7.2.0.GA-redhat-00005//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create[=11=](UndertowDeploymentInfoService.java:1502)
    at org.wildfly.extension.undertow@7.2.0.GA-redhat-00005//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create[=11=](UndertowDeploymentInfoService.java:1502)
    at org.wildfly.extension.undertow@7.2.0.GA-redhat-00005//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create[=11=](UndertowDeploymentInfoService.java:1502)
    at io.undertow.servlet@2.0.15.Final-redhat-00001//io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
    at io.undertow.servlet@2.0.15.Final-redhat-00001//io.undertow.servlet.handlers.ServletInitialHandler.access[=11=]0(ServletInitialHandler.java:81)
    at io.undertow.servlet@2.0.15.Final-redhat-00001//io.undertow.servlet.handlers.ServletInitialHandler.handleRequest(ServletInitialHandler.java:104)
    at io.undertow.core@2.0.15.Final-redhat-00001//io.undertow.server.Connectors.executeRootHandler(Connectors.java:360)
    at io.undertow.core@2.0.15.Final-redhat-00001//io.undertow.server.HttpServerExchange.run(HttpServerExchange.java:830)
    at org.jboss.threads@2.3.2.Final-redhat-1//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
    at org.jboss.threads@2.3.2.Final-redhat-1//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985)
    at org.jboss.threads@2.3.2.Final-redhat-1//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487)
    at org.jboss.threads@2.3.2.Final-redhat-1//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1378)
    at java.base/java.lang.Thread.run(Thread.java:834)

[161.908s][info][class,load] javax.faces.component.html.HtmlMessages$PropertyKeys source: jar:file:/C:/desarrollo/servers/jboss-eap-7.2/modules/system/layers/base/javax/faces/api/main/jboss-jsf-api_2.3_spec-2.3.5.SP1-redhat-1.jar!/
[161.914s][info][class,load] org.primefaces.model.DefaultStreamedContent source: vfs:/C:/desarrollo/workspace/accfor2/accfor/accfor-ear/target/accfor2/accfor-back.war/WEB-INF/lib/primefaces-10.0.0.jar
[161.915s][info][class,load] org.primefaces.model.DefaultStreamedContent$Builder source: vfs:/C:/desarrollo/workspace/accfor2/accfor/accfor-ear/target/accfor2/accfor-back.war/WEB-INF/lib/primefaces-10.0.0.jar
[161.916s][info][class,load] es.caib.accfor.presentation.back.ResourceBean$$Lambda33/0x0000000801c24840 source: es.caib.accfor.presentation.back.ResourceBean
[161.920s][info][class,load] org.apache.commons.io.IOUtils source: vfs:/C:/desarrollo/workspace/accfor2/accfor/accfor-ear/target/accfor2/accfor-back.war/WEB-INF/lib/commons-io-2.6.jar
[161.920s][info][class,load] org.apache.commons.io.output.StringBuilderWriter source: vfs:/C:/desarrollo/workspace/accfor2/accfor/accfor-ear/target/accfor2/accfor-back.war/WEB-INF/lib/commons-io-2.6.jar
[161.921s][info][class,load] org.apache.commons.io.output.ByteArrayOutputStream source: vfs:/C:/desarrollo/workspace/accfor2/accfor/accfor-ear/target/accfor2/accfor-back.war/WEB-INF/lib/commons-io-2.6.jar
[161.922s][info][class,load] org.apache.commons.io.Charsets source: vfs:/C:/desarrollo/workspace/accfor2/accfor/accfor-ear/target/accfor2/accfor-back.war/WEB-INF/lib/commons-io-2.6.jar
[161.934s][info][class,load] org.primefaces.component.graphicimage.GraphicImageRenderer$$Lambda34/0x0000000801c24c40 source: org.primefaces.component.graphicimage.GraphicImageRenderer
[161.935s][info][class,load] org.primefaces.util.DynamicContentSrcBuilder source: vfs:/C:/desarrollo/workspace/accfor2/accfor/accfor-ear/target/accfor2/accfor-back.war/WEB-INF/lib/primefaces-10.0.0.jar
[161.937s][info][class,load] org.primefaces.util.LimitedSizeHashMap source: vfs:/C:/desarrollo/workspace/accfor2/accfor/accfor-ear/target/accfor2/accfor-back.war/WEB-INF/lib/primefaces-10.0.0.jar

Persones.xhtml

<p:dataTable id="lstPersones" var="item" value="#{personesBean.items}" widgetVar="lstPersones"
             selection="#{personesBean.selected}" selectionMode="single"
             rowKey="#{item.id}"
             reflow="true" paginatorPosition="bottom" paginator="true" rows="10"
             rowsPerPageTemplate="10,25,50,100" emptyMessage="#{messages['noResultats']}"
             pageLinks="5" lazy="true"
             paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PageLinks} {LastPageLink} {RowsPerPageDropdown} {Exporters} {Buttons}"
             currentPageReportTemplate="#{messages['resultats']} #{messages['paginesDataList']}.">

    <p:ajax event="rowSelect" listener="#{personesBean.onRowSelect}"/>

    <f:facet name="{Exporters}">
        <h:commandLink>
            <p:graphicImage library="images/icons" name="xls.png"
                            title="#{messages['exportarXLS']}" style="border:0;"/>
            <p:dataExporter type="xls" target="lstPersones" fileName="export_persones"/>
        </h:commandLink>
    </f:facet>
    ...

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
         version="4.0">
...
    <context-param>
        <param-name>primefaces.THEME</param-name>
        <param-value>#{themeSwitcherBean.theme}</param-value>
    </context-param>
    <context-param>
        <param-name>primefaces.FONT_AWESOME</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>primefaces.CSP</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>server</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
        <param-value>false</param-value>
    </context-param>
...
</web-app>

终于找到p:dataExporter无法导出文件的问题了。

web.xml 文件包含定义为 false 的上下文参数 javax.faces.PARTIAL_STATE_SAVING,所以我注释掉了并且运行良好!

问题在web.xml

...
<context-param>
    <param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
    <param-value>false</param-value>
</context-param>
...