Bug primefaces 10 for - p:dataExporter and p:fileDownload

UI Components for JSF
Post Reply
vished
Posts: 473
Joined: 02 Feb 2014, 17:38

12 May 2021, 12:18

Hi,

I have upgraded to Primefaces 10.
It seems there is a huge bug for the p:dataExporter and p:fileDownload.
It was working in Primefaces 8 without issue.

Here a stacktrace:

Code: Select all

12:09:36,928 SEVERE [org.omnifaces.exceptionhandler.FullAjaxExceptionHandler] (default task-5) [e47a7136-b34b-4d9f-9e57-32186876ca83][127.0.0.1] FullAjaxExceptionHandler: An exception occurred during processing JSF ajax request. Error page '/error.xhtml' will be shown.: java.lang.ArrayIndexOutOfBoundsException: Index 2 out of bounds for length 2
	at javax.faces.api@3.0.0.SP04//javax.faces.component.UIComponentBase.restoreChildState(UIComponentBase.java:3418)
	at javax.faces.api@3.0.0.SP04//javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1026)
	at javax.faces.api@3.0.0.SP04//javax.faces.component.UIComponentBase.restoreFacetsState(UIComponentBase.java:3445)
Coming from class: javax.faces.component.UIComponentBase

Here an example:

Code: Select all

			<p:menuitem value="Download" update=":growl"
											icon="fa fa-download" global="true" immediate="true"
											ajax="false"
											actionListener="#{generalDocumentController.doDownloadDocument(offer)}">
											<p:fileDownload
												value="#{generalDocumentController.streamFile}" />
										</p:menuitem>

Bean:

Code: Select all

@ViewScoped
@Named
public class GeneralDocumentController implements Serializable {

	private static final long serialVersionUID = -6695529018699874351L;

private StreamedContent streamFile;	
	
	public void doDownloadDocument(DocumentInterface documentInterface) {

		try {

			InputStream stream = new FileInputStream(documentInterface.getFilePathCurrentDocument());

			streamFile = DefaultStreamedContent.builder().contentType("application/pdf")
					.name(documentInterface.getFileName() + ".pdf").stream(() -> stream).build();

		} catch (Exception e) {
			LOGGER.error(ExceptionUtils.getFullStackTrace(e));
			ErrorMessage.showErrorMessage();
		}
	}
	
		public StreamedContent getStreamFile() {
		return streamFile;
	}

	public void setStreamFile(StreamedContent streamFile) {
		this.streamFile = streamFile;
	}
	
Here my web.xml

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="4.0"
	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">



	<servlet>
		<servlet-name>OpenApi</servlet-name>
		<servlet-class>io.swagger.v3.jaxrs2.integration.OpenApiServlet</servlet-class>
		<init-param>
			<param-name>openApi.configuration.resourcePackages</param-name>
			<param-value>io.swagger.sample.resource</param-value>
		</init-param>
		<init-param>
			<param-name>openApi.configuration.alwaysResolveAppPath</param-name>
			<param-value>true</param-value>
		</init-param>
	</servlet>
	<servlet-mapping>
		<servlet-name>OpenApi</servlet-name>
		<url-pattern>/openapi/*</url-pattern>
	</servlet-mapping>


	<!-- sets the default session timeout to 480 minutes. -->
	<session-config>
		<session-timeout>480</session-timeout>
	</session-config>



	<listener>
		<listener-class>com.controller.ChatOnlineListener</listener-class>
	</listener>


	<context-param>
		<param-name>javax.faces.PROJECT_STAGE</param-name>
		<param-value>Production</param-value>
	</context-param>


	<context-param>
		<param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name>
		<param-value>0</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.FACELETS_SKIP_COMMENTS</param-name>
		<param-value>true</param-value>
	</context-param>

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

	<context-param>
		<param-name>javax.faces.FACELETS_BUFFER_SIZE</param-name>
		<param-value>65536</param-value>
	</context-param>

	


	<servlet>
		<servlet-name>facesServlet</servlet-name>
		<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
		<load-on-startup>1</load-on-startup>
	</servlet>


	<!-- Map following files to the JSF servlet -->
	<servlet-mapping>
		<servlet-name>facesServlet</servlet-name>
		<url-pattern>*.jsf</url-pattern>
		<url-pattern>*.xhtml</url-pattern>
	</servlet-mapping>



	<context-param>
		<param-name>primefaces.THEME</param-name>
		<param-value>#{themeSwitcher.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>javax.faces.FACELETS_LIBRARIES</param-name>
		<param-value>/WEB-INF/primefaces-morpheus.taglib.xml</param-value>
	</context-param>

	<context-param>
		<param-name>javax.faces.FACELETS_LIBRARIES</param-name>
		<param-value>/WEB-INF/primefaces-verona.taglib.xml</param-value>
	</context-param>

	<!-- <filter> <filter-name>Character Encoding Filter</filter-name> <filter-class>org.primefaces.morpheus.filter.CharacterEncodingFilter</filter-class> 
		</filter> -->

	<listener>
		<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
	</listener>

	<context-param>
		<param-name>primefaces.SUBMIT</param-name>
		<param-value>partial</param-value>
	</context-param>

	<context-param>
		<param-name>primefaces.CACHE_PROVIDER</param-name>
		<param-value>org.primefaces.cache.EHCacheProvider</param-value>
	</context-param>

	<context-param>
		<param-name>primefaces.MOVE_SCRIPTS_TO_BOTTOM</param-name>
		<param-value>true</param-value>
	</context-param>

	<context-param>
		<param-name>primefaces.PUBLIC_CAPTCHA_KEY</param-name>
		<param-value>6LcauXIUAAAAAGA03uvKNni_U9ehsrktuKhMY9A5</param-value>
	</context-param>

	<context-param>
		<param-name>primefaces.PRIVATE_CAPTCHA_KEY</param-name>
		<param-value>6LcauXIUAAAAAKopsAGjQkzwfdpPYVCNbwPsJGYV</param-value>
	</context-param>


	<!-- Disable ViewState compression (better performance but more memory usage) -->
	<context-param>
		<param-name>com.sun.faces.compressViewState</param-name>
		<param-value>false</param-value>
	</context-param>


	<context-param>
		<param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
		<param-value>true</param-value>
	</context-param>


	<!-- Context parameters - Mojarra -->
	<context-param>
		<param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
		<param-value>false</param-value>
	</context-param>
	<context-param>
		<param-name>com.sun.faces.disableIdUniquenessCheck</param-name>
		<param-value>true</param-value>
	</context-param>
	<!-- reduce saved view states -->
	<context-param>
		<param-name>com.sun.faces.numberOfViewsInSession</param-name>
		<param-value>15</param-value>
	</context-param>


	<!-- Disable ViewState compression (better performance but more memory usage) -->
	<context-param>
		<param-name>com.sun.faces.compressViewState</param-name>
		<param-value>false</param-value>
	</context-param>
	<!-- Context parameters - OmniFaces -->
	<context-param>
		<param-name>org.omnifaces.COMBINED_RESOURCE_HANDLER_DISABLED</param-name>
		<param-value>#{facesContext.application.projectStage eq 'Development'}</param-value>
	</context-param>




	<!-- Websocket Omnifaces -->
	<context-param>
		<param-name>org.omnifaces.SOCKET_ENDPOINT_ENABLED</param-name>
		<param-value>true</param-value>
	</context-param>

	<!-- Ignore from logging -->
	<context-param>
		<param-name>org.omnifaces.EXCEPTION_TYPES_TO_IGNORE_IN_LOGGING</param-name>
		<param-value>javax.faces.application.ViewExpiredException</param-value>
	</context-param>


	<error-page>
		<exception-type>javax.faces.application.ViewExpiredException</exception-type>
		<location>/common/expired.xhtml</location>
	</error-page>
	<error-page>
		<exception-type>java.sql.SQLException</exception-type>
		<location>/common/login.xhtml</location>
	</error-page>
	<error-page>
		<exception-type>java.lang.RuntimeException</exception-type>
		<location>/common/login.xhtml</location>
	</error-page>

	<error-page>
		<exception-type>org.apache.shiro.session.InvalidSessionException</exception-type>
		<location>/common/error.xhtml</location>
	</error-page>

	<error-page>
		<error-code>500</error-code>
		<location>/common/404.xhtml</location>
	</error-page>
	<error-page>
		<error-code>404</error-code>
		<location>/common/404.xhtml</location>
	</error-page>
	<error-page>
		<error-code>400</error-code>
		<location>/common/login.xhtml</location>
	</error-page>

	<error-page>
		<error-code>401</error-code>
		<location>/common/access-denied.xhtml</location>
	</error-page>

	<context-param>
		<param-name>com.sun.faces.writeStateAtFormEnd</param-name>
		<param-value>false</param-value>
	</context-param>


	<context-param>
		<param-name>primefaces.UPLOADER</param-name>
		<param-value>commons</param-value>
	</context-param>

	<filter>
		<filter-name>PrimeFaces FileUpload Filter</filter-name>
		<filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
	</filter>

	<filter-mapping>
		<filter-name>PrimeFaces FileUpload Filter</filter-name>
		<servlet-name>facesServlet</servlet-name>
		<dispatcher>REQUEST</dispatcher>
		<dispatcher>FORWARD</dispatcher>
	</filter-mapping>


	<context-param>
		<param-name>org.primefaces.extensions.DELIVER_UNCOMPRESSED_RESOURCES</param-name>
		<param-value>true</param-value>
	</context-param>

	<context-param>
		<param-name>org.primefaces.extensions.WRAP_PRIME_FACES_RESOURCES</param-name>
		<param-value>true</param-value>
	</context-param>

	<context-param>
		<param-name>primefaces.CACHE_PROVIDER</param-name>
		<param-value>org.primefaces.cache.EHCacheProvider</param-value>
	</context-param>

	<!-- <context-param> <param-name>org.omnifaces.COMBINED_RESOURCE_HANDLER_EXCLUDED_RESOURCES</param-name> 
		<param-value>primefaces-extensions:primefaces-extensions.js </param-value> 
		</context-param> -->

	<context-param>
		<param-name>javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE</param-name>
		<param-value>true</param-value>
	</context-param>




	<!-- Start For activate Shrio Muss wieder aktiviert werden, wenn der CustoermEnvironmentLoaderListener 
		nicht aktiv ist -->
	<listener>
		<listener-class>org.apache.shiro.web.env.EnvironmentLoaderListener</listener-class>
	</listener>


	<context-param>
		<param-name>shiroEnvironmentClass</param-name>
		<param-value>org.apache.shiro.web.env.IniWebEnvironment</param-value>
	</context-param>
	<context-param>
		<param-name>shiroConfigLocations</param-name>
		<param-value>classpath:shiro-web.ini</param-value>
	</context-param>

	<!-- Shiro first, no dispatcher setting required -->
	<filter>
		<filter-name>ShiroFilter</filter-name>
		<filter-class>org.apache.shiro.web.servlet.ShiroFilter</filter-class>
	</filter>

	<filter-mapping>
		<filter-name>ShiroFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>



	<!-- Rewrite after that -->
	<filter>
		<filter-name>OCPsoft Rewrite Filter</filter-name>
		<filter-class>org.ocpsoft.rewrite.servlet.RewriteFilter</filter-class>
		<async-supported>true</async-supported>
	</filter>
	<filter-mapping>
		<filter-name>OCPsoft Rewrite Filter</filter-name>
		<url-pattern>/*</url-pattern>
		<dispatcher>FORWARD</dispatcher>
		<dispatcher>REQUEST</dispatcher>
		<dispatcher>INCLUDE</dispatcher>
		<dispatcher>ASYNC</dispatcher>
		<dispatcher>ERROR</dispatcher>
	</filter-mapping>



	<filter>
		<filter-name>characterEncodingFilter</filter-name>
		<filter-class>org.omnifaces.filter.CharacterEncodingFilter</filter-class>
	</filter>

	<filter-mapping>
		<filter-name>characterEncodingFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>


	<!-- Apply GZIP compression on responses whenever applicable -->
	<filter>
		<filter-name>GzipResponseFilter</filter-name>
		<filter-class>org.omnifaces.filter.GzipResponseFilter</filter-class>
		<init-param>
			<description>The mimetypes which needs to be compressed. Must be a commaseparated string. Defaults to the below values.</description>
			<param-name>mimetypes</param-name>
			<param-value>
        text/plain, text/html, text/xml, text/css, text/javascript, text/csv, text/rtf,
        application/xml, application/xhtml+xml, application/javascript, application/json,
        image/svg+xml, application/x-javascript
            </param-value>
		</init-param>
	</filter>
	<filter-mapping>
		<filter-name>GzipResponseFilter</filter-name>
		<servlet-name>Faces Servlet</servlet-name>
	</filter-mapping>


	<!-- No Cache Filter -->
	<filter>
		<filter-name>NoCacheFilter</filter-name>
		<filter-class>org.omnifaces.filter.CacheControlFilter</filter-class>
	</filter>
	<filter-mapping>
		<filter-name>NoCacheFilter</filter-name>
		<servlet-name>Faces Servlet</servlet-name>
	</filter-mapping>



	<!-- <filter> <filter-name>noCacheFilter</filter-name> <filter-class>org.omnifaces.filter.CacheControlFilter</filter-class> 
		</filter> <filter-mapping> <filter-name>noCacheFilter</filter-name> <servlet-name>facesServlet</servlet-name> 
		</filter-mapping> -->

	<context-param>
		<param-name>com.sun.faces.defaultResourceMaxAge</param-name>
		<param-value>3628800000</param-value> <!-- 6 weeks. -->
	</context-param>

	<filter>
		<filter-name>gzipResponseFilter</filter-name>
		<filter-class>org.omnifaces.filter.GzipResponseFilter</filter-class>
	</filter>
	<filter-mapping>
		<filter-name>gzipResponseFilter</filter-name>
		<url-pattern>/*</url-pattern>
		<dispatcher>REQUEST</dispatcher>
		<dispatcher>ERROR</dispatcher>
	</filter-mapping>




	<!-- web fonts -->
	<mime-mapping>
		<extension>eot</extension>
		<mime-type>application/vnd.ms-fontobject</mime-type>
	</mime-mapping>
	<mime-mapping>
		<extension>otf</extension>
		<mime-type>font/opentype</mime-type>
	</mime-mapping>
	<mime-mapping>
		<extension>ttf</extension>
		<mime-type>application/x-font-ttf</mime-type>
	</mime-mapping>
	<mime-mapping>
		<extension>woff</extension>
		<mime-type>application/x-font-woff</mime-type>
	</mime-mapping>
	<mime-mapping>
		<extension>pdf</extension>
		<mime-type>application/pdf</mime-type>
	</mime-mapping>
	<mime-mapping>
		<extension>svg</extension>
		<mime-type>image/svg+xml</mime-type>
	</mime-mapping>

	<mime-mapping>
		<extension>ttf</extension>
		<mime-type>application/font-sfnt</mime-type>
	</mime-mapping>
	<mime-mapping>
		<extension>woff</extension>
		<mime-type>application/font-woff</mime-type>
	</mime-mapping>
	<mime-mapping>
		<extension>woff2</extension>
		<mime-type>application/font-woff2</mime-type>
	</mime-mapping>
	<mime-mapping>
		<extension>eot</extension>
		<mime-type>application/vnd.ms-fontobject</mime-type>
	</mime-mapping>
	<mime-mapping>
		<extension>eot?#iefix</extension>
		<mime-type>application/vnd.ms-fontobject</mime-type>
	</mime-mapping>
	<mime-mapping>
		<extension>svg</extension>
		<mime-type>image/svg+xml</mime-type>
	</mime-mapping>
	<mime-mapping>
		<extension>svg#exosemibold</extension>
		<mime-type>image/svg+xml</mime-type>
	</mime-mapping>
	<mime-mapping>
		<extension>svg#exobolditalic</extension>
		<mime-type>image/svg+xml</mime-type>
	</mime-mapping>
	<mime-mapping>
		<extension>svg#exomedium</extension>
		<mime-type>image/svg+xml</mime-type>
	</mime-mapping>
	<mime-mapping>
		<extension>svg#exoregular</extension>
		<mime-type>image/svg+xml</mime-type>
	</mime-mapping>
	<mime-mapping>
		<extension>svg#fontawesomeregular</extension>
		<mime-type>image/svg+xml</mime-type>
	</mime-mapping>


</web-app>
Any idea how this can be solved?
I´m using: javax.faces.api@3.0.0.SP04
PF 8.0

Melloware
Posts: 2653
Joined: 22 Apr 2013, 15:48

12 May 2021, 13:38

Looks like same as this user: viewtopic.php?f=3&t=66776
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 10.0.2 / PF Extensions 10.0.2

vished
Posts: 473
Joined: 02 Feb 2014, 17:38

12 May 2021, 16:58

Yes, any ideas?
PF 8.0

Melloware
Posts: 2653
Joined: 22 Apr 2013, 15:48

13 May 2021, 16:35

I would create a PrimeFaces Test reproducer and if you can reproduce it open a GitHub ticket.
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 10.0.2 / PF Extensions 10.0.2

Melloware
Posts: 2653
Joined: 22 Apr 2013, 15:48

23 May 2021, 18:17

Turns out its a Mojarra bug and works fine on MyFaces.

See: https://github.com/primefaces/primefaces/issues/7343

Mojarra Bug: https://github.com/eclipse-ee4j/mojarra/issues/4936
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 10.0.2 / PF Extensions 10.0.2

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 22 guests