Search code examples
jsfprimefaceskeycloakexporterarrayindexoutofboundsexception

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


Environment:

  • Jboss 7.2
  • Primefaces 10
  • Java 11

I have migrated from primefaces 8 to primefaces 10 dataTable p:dataExporter generate ArrayIndexOutOfBoundsException on render the xhtml. When I comment out dataexporter the xhtml render well.

Following the migration guide the only important change seems to be taht PDF library has been switched from iText to Libre OpenPDF.

I've tried two differents contexts and one works and one not, differences:

  • The context that it works, does not have authentication
  • The context that it does not work, have keycloack authentication and two themes dependencies.

I don't think is related with primefaces themes but it could be because of keycloak as it shows handeling request in log error.

Any reason why is giving this error?

Server error

[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 [email protected]//javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1439)
    at [email protected]//javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1460)
    at [email protected]//javax.faces.component.UIViewRoot.processRestoreState(UIViewRoot.java:955)
    at [email protected]//com.sun.faces.application.view.JspStateManagementStrategy.restoreView(JspStateManagementStrategy.java:273)
    at [email protected]//com.sun.faces.application.StateManagerImpl.restoreView(StateManagerImpl.java:139)
    at [email protected]//com.sun.faces.application.view.ViewHandlingStrategy.restoreView(ViewHandlingStrategy.java:123)
    at [email protected]//com.sun.faces.application.view.FaceletViewHandlingStrategy.restoreView(FaceletViewHandlingStrategy.java:295)
    at [email protected]//com.sun.faces.application.view.MultiViewHandler.restoreView(MultiViewHandler.java:157)
    at [email protected]//javax.faces.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:125)
    at [email protected]//javax.faces.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:125)
    at [email protected]//com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:204)
    at [email protected]//com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
    at [email protected]//com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:133)
    at [email protected]//com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:201)
    at [email protected]//javax.faces.webapp.FacesServlet.service(FacesServlet.java:670)
    at [email protected]//io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)
    at [email protected]//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 [email protected]//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
    at [email protected]//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 [email protected]//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
    at [email protected]//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 [email protected]//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
    at [email protected]//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 [email protected]//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
    at [email protected]//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
    at [email protected]//io.opentracing.contrib.jaxrs2.server.SpanFinishingFilter.doFilter(SpanFinishingFilter.java:55)
    at [email protected]//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
    at [email protected]//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
    at [email protected]//io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
    at [email protected]//io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
    at [email protected]//io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)
    at [email protected]//io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
    at [email protected]//org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
    at [email protected]//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at [email protected]//org.keycloak.adapters.undertow.UndertowAuthenticatedActionsHandler.handleRequest(UndertowAuthenticatedActionsHandler.java:66)
    at [email protected]//io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132)
    at [email protected]//io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
    at [email protected]//io.undertow.server.handlers.DisableCacheHandler.handleRequest(DisableCacheHandler.java:33)
    at [email protected]//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at [email protected]//io.undertow.security.handlers.AuthenticationConstraintHandler.handleRequest(AuthenticationConstraintHandler.java:53)
    at [email protected]//io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
    at [email protected]//io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
    at [email protected]//io.undertow.servlet.handlers.security.ServletSecurityConstraintHandler.handleRequest(ServletSecurityConstraintHandler.java:59)
    at [email protected]//io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
    at [email protected]//io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
    at [email protected]//io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
    at [email protected]//io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
    at [email protected]//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at [email protected]//org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
    at [email protected]//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at [email protected]//org.wildfly.extension.undertow.deployment.GlobalRequestControllerHandler.handleRequest(GlobalRequestControllerHandler.java:68)
    at [email protected]//org.keycloak.adapters.undertow.ServletPreAuthActionsHandler.handleRequest(ServletPreAuthActionsHandler.java:69)
    at [email protected]//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)
    at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
    at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
    at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
    at [email protected]//io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
    at [email protected]//io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
    at [email protected]//org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)
    at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
    at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
    at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
    at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
    at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
    at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
    at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
    at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
    at [email protected]//io.undertow.server.Connectors.executeRootHandler(Connectors.java:360)
    at [email protected]//io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830)
    at [email protected]//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
    at [email protected]//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985)
    at [email protected]//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487)
    at [email protected]//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$$Lambda$1133/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$$Lambda$1134/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>

Solution

  • I finally found the problem why I could not export files with p:dataExporter.

    The web.xml file contained the context param javax.faces.PARTIAL_STATE_SAVING defined to false, so I commented out and I worked well!

    The problem in web.xml

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