Skip to content

Commit 4a3f15d

Browse files
committed
disable/remove theme settings since them do not work proper and not neccessary for this demo, in pom.xml and JSFConfiguration
describe the problem in README.md Change Spring Boot Version to 1.5.3.RELEASE
1 parent 62c6a54 commit 4a3f15d

File tree

3 files changed

+135
-115
lines changed

3 files changed

+135
-115
lines changed

README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,36 @@
11
Spring-Boot-JSF-Example
22
=======================
33

4-
Fork of Zergleb's Spring Boot + JSF Integration
4+
Fork of Zergleb's Spring Boot + JSF Integration, forked from cenobyte321/Spring-Boot-JSF-Example
5+
6+
7+
# This is a demonstration that there is probably a _bug/error/feature/_ during the creation of an executable .war file with spring-boot-maven-plugin since Version >= 1.5.3.RELEASE
8+
9+
Build it with
10+
11+
_mvn clean install spring-boot:repackage_
12+
13+
and try to execute it with
14+
15+
_java -jar target/application-0.0.1-SNAPSHOT.war_
16+
17+
You will get during startup an Exception like this :
18+
19+
20+
*2017-09-08 10:48:23.860 INFO 35369 --- [ost-startStop-1] j.e.resource.webcontainer.jsf.config : Mojarra 2.2.7 ( 20140610-1547 https://svn.java.net/svn/mojarra~svn/tags/2.2.7@13362) für Kontext '' wird initialisiert.*
21+
22+
*2017-09-08 10:48:27.938 ERROR 35369 --- [ost-startStop-1] j.e.resource.webcontainer.jsf.config : Critical error during deployment:*
23+
24+
*com.sun.faces.config.ConfigurationException: java.util.concurrent.ExecutionException: javax.faces.FacesException: java.io.FileNotFoundException: JAR entry META-INF/ not found in /var/folders/gj/...*
25+
26+
27+
Changing spring-boot-parent version in pom to something lower 1.5.3.RELEASE it works fine.
28+
29+
30+
31+
32+
33+
###Original Readme
534

635
##Changes##
736

pom.xml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,20 @@
1010

1111
<name>application</name>
1212
<description>Spring JSF Example with MAven</description>
13-
13+
14+
<properties>
15+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
16+
<java.version>1.8</java.version>
17+
</properties>
18+
1419
<parent>
1520
<groupId>org.springframework.boot</groupId>
1621
<artifactId>spring-boot-starter-parent</artifactId>
17-
<version>1.5.1.RELEASE</version>
22+
<version>1.5.3.RELEASE</version>
1823
<relativePath/> <!-- lookup parent from repository -->
1924
</parent>
2025

21-
<properties>
22-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
23-
<java.version>1.8</java.version>
24-
</properties>
26+
2527

2628
<dependencies>
2729
<dependency>
@@ -115,11 +117,6 @@
115117
<artifactId>spring-security-taglibs</artifactId>
116118
<version>3.2.7.RELEASE</version>
117119
</dependency>
118-
<dependency>
119-
<groupId>org.primefaces.extensions</groupId>
120-
<artifactId>all-themes</artifactId>
121-
<version>1.0.8</version>
122-
</dependency>
123120
<dependency>
124121
<groupId>org.apache.commons</groupId>
125122
<artifactId>commons-io</artifactId>
Lines changed: 97 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
12
package application.configuration.jsf;
3+
24
import java.util.EnumSet;
35
import java.util.HashMap;
46

5-
67
import javax.faces.webapp.FacesServlet;
78
import javax.servlet.DispatcherType;
89
import javax.servlet.ServletContext;
@@ -15,114 +16,107 @@
1516
import org.springframework.boot.web.servlet.ServletRegistrationBean;
1617
import org.springframework.context.annotation.Bean;
1718
import org.springframework.context.annotation.Configuration;
19+
import org.springframework.web.filter.DelegatingFilterProxy;
1820

1921
import com.sun.faces.config.ConfigureListener;
20-
import org.springframework.web.filter.DelegatingFilterProxy;
2122

2223
/**
2324
* Created by anonymous on 1/31/16.
2425
*/
2526
@Configuration
2627
public class JSFConfiguration {
27-
/**
28-
* Configuración de ViewScope
29-
*
30-
* @return ViewScope
31-
*/
32-
@Bean
33-
public static ViewScope viewScope() {
34-
return new ViewScope();
35-
}
36-
37-
/**
38-
* Allows the use of @Scope("view") on Spring @Component, @Service and @Controller
39-
* beans
40-
*/
41-
@Bean
42-
public static CustomScopeConfigurer scopeConfigurer() {
43-
CustomScopeConfigurer configurer = new CustomScopeConfigurer();
44-
HashMap<String, Object> hashMap = new HashMap<String, Object>();
45-
hashMap.put("view", viewScope());
46-
configurer.setScopes(hashMap);
47-
return configurer;
48-
}
49-
50-
/*
51-
* Below sets up the Faces Servlet for Spring Boot
52-
*/
53-
@Bean
54-
public FacesServlet facesServlet() {
55-
return new FacesServlet();
56-
}
57-
58-
/**
59-
* Configuración de JSF
60-
*
61-
* @return
62-
*/
63-
@Bean
64-
public ServletRegistrationBean facesServletRegistration() {
65-
ServletRegistrationBean registration = new ServletRegistrationBean(
66-
facesServlet(), "*.xhtml");
67-
registration.setName("FacesServlet");
68-
registration.setLoadOnStartup(1);
69-
return registration;
70-
}
71-
72-
/**
73-
* Configuración de JSF
74-
*
75-
* @return
76-
*/
77-
@Bean
78-
public ServletListenerRegistrationBean<ConfigureListener> jsfConfigureListener() {
79-
return new ServletListenerRegistrationBean<ConfigureListener>(
80-
new ConfigureListener());
81-
}
82-
83-
/**
84-
* Configuración de servlet startup de JSF
85-
*
86-
* @return
87-
*/
88-
@Bean
89-
public ServletContextInitializer initializer() {
90-
return new ServletContextInitializer() {
91-
92-
@Override
93-
public void onStartup(ServletContext servletContext)
94-
throws ServletException {
95-
96-
//Los parámetros del servlet (web.xml) son agregados aquí
97-
//De todas formas se debe de dejar el archivo web.xml para que no arroje errores JSF
98-
99-
//Asignamos el tema de Bootstrap
100-
servletContext.setInitParameter("primefaces.THEME",
101-
"bootstrap");
102-
servletContext.setInitParameter("javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL","true");
103-
104-
//Configuración de taglibs con Spring Security
105-
servletContext.setInitParameter(
106-
"com.sun.faces.forceLoadConfiguration", "true");
107-
servletContext.setInitParameter(
108-
"javax.faces.FACELETS_LIBRARIES",
109-
"/WEB-INF/springsecurity.taglib.xml");
110-
servletContext.setInitParameter("javax.faces.FACELETS_LIBRARIES", "/WEB-INF/springsecurity.taglib.xml");
111-
112-
EnumSet<DispatcherType> tiposDispatcher = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD);
113-
servletContext.addFilter("securityFilter",
114-
new DelegatingFilterProxy("springSecurityFilterChain")).addMappingForUrlPatterns(tiposDispatcher, false, "/*");
115-
116-
//Configuración del filter upload de Primefaces
117-
servletContext.setInitParameter("primefaces.UPLOADER", "commons");
118-
servletContext.addFilter("PrimeFaces FileUpload Filter", new FileUploadFilter())
119-
.addMappingForServletNames(tiposDispatcher, false, "FacesServlet");
120-
121-
//ViewExpiredException filter register
122-
servletContext.addFilter("errorHandlerFilter", new ViewExpiredExceptionFilter())
123-
.addMappingForUrlPatterns(tiposDispatcher,false, "/*");
124-
125-
}
126-
};
127-
}
28+
/**
29+
* Configuración de ViewScope
30+
*
31+
* @return ViewScope
32+
*/
33+
@Bean
34+
public static ViewScope viewScope() {
35+
return new ViewScope();
36+
}
37+
38+
/**
39+
* Allows the use of @Scope("view") on Spring @Component, @Service and @Controller
40+
* beans
41+
*/
42+
@Bean
43+
public static CustomScopeConfigurer scopeConfigurer() {
44+
CustomScopeConfigurer configurer = new CustomScopeConfigurer();
45+
HashMap<String, Object> hashMap = new HashMap<String, Object>();
46+
hashMap.put("view", viewScope());
47+
configurer.setScopes(hashMap);
48+
return configurer;
49+
}
50+
51+
/*
52+
* Below sets up the Faces Servlet for Spring Boot
53+
*/
54+
@Bean
55+
public FacesServlet facesServlet() {
56+
return new FacesServlet();
57+
}
58+
59+
/**
60+
* Configuración de JSF
61+
*
62+
* @return
63+
*/
64+
@Bean
65+
public ServletRegistrationBean facesServletRegistration() {
66+
ServletRegistrationBean registration = new ServletRegistrationBean(
67+
facesServlet(), "*.xhtml");
68+
registration.setName("FacesServlet");
69+
registration.setLoadOnStartup(1);
70+
return registration;
71+
}
72+
73+
/**
74+
* Configuración de JSF
75+
*
76+
* @return
77+
*/
78+
@Bean
79+
public ServletListenerRegistrationBean<ConfigureListener> jsfConfigureListener() {
80+
return new ServletListenerRegistrationBean<ConfigureListener>(
81+
new ConfigureListener());
82+
}
83+
84+
/**
85+
* Configuración de servlet startup de JSF
86+
*
87+
* @return
88+
*/
89+
@Bean
90+
public ServletContextInitializer initializer() {
91+
return new ServletContextInitializer() {
92+
93+
@Override
94+
public void onStartup(ServletContext servletContext)
95+
throws ServletException {
96+
97+
// Los parámetros del servlet (web.xml) son agregados aquí
98+
// De todas formas se debe de dejar el archivo web.xml para que no arroje errores JSF
99+
100+
servletContext.setInitParameter("javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL", "true");
101+
102+
// Configuración de taglibs con Spring Security
103+
servletContext.setInitParameter("com.sun.faces.forceLoadConfiguration", "true");
104+
servletContext.setInitParameter("javax.faces.FACELETS_LIBRARIES", "/WEB-INF/springsecurity.taglib.xml");
105+
106+
EnumSet<DispatcherType> tiposDispatcher = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD);
107+
servletContext.addFilter("securityFilter",
108+
new DelegatingFilterProxy("springSecurityFilterChain")).addMappingForUrlPatterns(tiposDispatcher, false, "/*");
109+
110+
// Configuración del filter upload de Primefaces
111+
servletContext.setInitParameter("primefaces.UPLOADER", "commons");
112+
servletContext.addFilter("PrimeFaces FileUpload Filter", new FileUploadFilter())
113+
.addMappingForServletNames(tiposDispatcher, false, "FacesServlet");
114+
115+
// ViewExpiredException filter register
116+
servletContext.addFilter("errorHandlerFilter", new ViewExpiredExceptionFilter())
117+
.addMappingForUrlPatterns(tiposDispatcher, false, "/*");
118+
119+
}
120+
};
121+
}
128122
}

0 commit comments

Comments
 (0)