I\'m running my JSF project launching it with Spring Boot and taking advantage of the whole Spring environment. The configuration is: Mojarra 2.2.8 + Primefaces 5.1 + Spring
Finally, I got it working using the Apache Commons library. Similarly that what we might do in a standard web.xml file, that's my context initializer:
@Bean
public ServletContextInitializer initializer() {
return new ServletContextInitializer() {
@Override
public void onStartup(ServletContext servletContext)
throws ServletException {
servletContext.setInitParameter("primefaces.THEME", "bluesky");
servletContext.setInitParameter(
"javax.faces.FACELETS_SKIP_COMMENTS", "true");
servletContext.setInitParameter(
"com.sun.faces.expressionFactory",
"com.sun.el.ExpressionFactoryImpl");
servletContext.setInitParameter("primefaces.UPLOADER",
"commons");
}
};
}
I explicitly tell Primefaces to use the commons uploader, like said in docs (the other choice is to use native, which is not working).
Then, just adding this two dependencies to the project, we're ready to go:
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.2</version>
</dependency>
I keep the thread opened for some response based in the native mode.
See also:
Just to put my two cents, with Spring boot 1.4.2.RELEASE, Primefaces 6.0, OCP Soft rewrite 2.0.12.Final, JSF 2.1.29-08 and application deployed on Tomcat 8, I also need to disable spring hiddenHttpMethodFilter.
@Bean
public FilterRegistrationBean hiddenHttpMethodFilterDisabled(
@Qualifier("hiddenHttpMethodFilter") HiddenHttpMethodFilter filter) {
FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(filter);
filterRegistrationBean.setEnabled(false);
return filterRegistrationBean;
}
I have spent with this issue almost two days and as last thing I have tried to disable spring filters one by one, so I hope it will help someone.
It could be also necessary to transfer xml filter configuration to Java-based Config :
<filter-mapping>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
to your @Configuration
@Bean
public FilterRegistrationBean FileUploadFilter() {
FilterRegistrationBean registration = new FilterRegistrationBean();
registration.setFilter(new org.primefaces.webapp.filter.FileUploadFilter());
registration.setName("PrimeFaces FileUpload Filter");
return registration;
}
in combination with the above answer it work for me