How to Integrate JSF With Spring Boot Applications
Run JSF pages inside Spring Boot: the JoinFaces starter, Mojarra setup, Spring beans in EL, scopes, Spring Security login and packaging as a jar.

Spring Boot has no JSF support of its own, and JSF predates Boot by a decade, so combining them needs a bridge. The project that provides it is JoinFaces, which supplies starters that register the Faces servlet, pick a Faces implementation and component libraries, and make Spring beans available to Faces pages. The combination is attractive for a team with Faces skills and screens that wants Boot's packaging, configuration and Spring Data or Spring Security. It also has several seams where the two models disagree, in scopes, transactions and lazy loading. This post sets up the integration with Boot 4 and JoinFaces, then covers beans, scopes, security, data access and packaging. It uses Jakarta Faces 4 and JDK 25. If you are new to the technology, start with the JSF tutorial.
Dependencies
<dependency>
<groupId>org.joinfaces</groupId>
<artifactId>jsf-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.joinfaces</groupId>
<artifactId>primefaces-spring-boot-starter</artifactId>
</dependency>The JoinFaces BOM manages versions and must match your Boot version: JoinFaces releases track Boot majors, so check the compatibility table on the project site before upgrading either. The first starter brings the Faces implementation (Mojarra by default, MyFaces as an alternative), the servlet registration and the Spring integration. The second adds PrimeFaces and its configuration. There are starters for other component libraries and for Spring Security integration. JoinFaces reads configuration under joinfaces.* and jsf.* properties, with defaults for development mode and the project stage.
Layout and a page
Boot's embedded server serves Faces pages from src/main/resources/META-INF/resources, which is the web root for a jar:
src/main/resources/META-INF/resources/
index.xhtml
orders/list.xhtml
resources/css/site.css
src/main/java/com/example/web/OrderBean.javaPages are requested with the .xhtml extension by default; JoinFaces can map *.jsf or *.faces too. Packaging as a jar with the embedded server keeps src/main/webapp out of play (it is not packaged into an executable jar), which surprises people who expect a WAR layout. If you package a WAR for an external server, the standard src/main/webapp location works.
Spring beans as managed beans
Faces expressions resolve names through the EL resolver, and JoinFaces plugs the Spring context into it. A Spring bean is visible in a page by its bean name:
@Component
@Scope("view")
public class OrderBean {
private final OrderService orders;
private List<OrderRow> rows;
public OrderBean(OrderService orders) { this.orders = orders; }
@PostConstruct
void load() { rows = orders.recent(); }
public List<OrderRow> getRows() { return rows; }
public void cancel(Long id) { orders.cancel(id); load(); }
}<p:dataTable value="#{orderBean.rows}" var="o">
<p:column headerText="Number">#{o.number}</p:column>
<p:column><p:commandButton value="Cancel" action="#{orderBean.cancel(o.id)}" update="@form"/></p:column>
</p:dataTable>The bean name is the class name with a lower-case first letter, as in Spring. Constructor injection works, since Spring creates the bean, so the Faces-style @ManagedProperty and @Inject into a managed bean are unnecessary. Annotate with Spring stereotypes, not with @ManagedBean or @Named: mixing the Faces and CDI annotations in a Spring Boot application is a common source of beans that never get created, and the failure is Target Unreachable, identifier 'orderBean' resolved to null, whose causes are listed in the Target Unreachable fix in the earlier cluster, where the first thing to check is that the bean is in a scanned package.
Scopes
The Faces scopes that matter (view, flash, and the conversation-like ones) are not Spring's. JoinFaces registers a Spring scope named view that stores beans in the Faces view map, and @Scope("view") as above gives a bean that lives as long as the user stays on the page, surviving postbacks and AJAX calls. The alternatives are request, session and singleton, with Spring's meaning. The scopes and their trade-offs in Faces terms are in JSF bean scopes.
Two cautions. A view-scoped bean is stored in the session or in the client state with the view, so it must be serializable when the session is replicated or persisted, and must not hold references to non-serializable Spring beans, which should be injected with transient fields or accessed through the context. And a singleton bean must never hold per-user state, which is the usual mistake of developers coming from @ManagedBean(eager) patterns: a field set by one user shows up for the next.
Security
Spring Security protects Faces pages like any servlet resource, with a SecurityFilterChain that matches URL patterns. Two Faces-specific points apply. CSRF protection: Faces has its own token in the view state for postbacks, and Spring Security's CSRF filter also expects a token on POSTs; JoinFaces' Spring Security starter and the h:form integration write the Spring token into forms so that both work. Test every POST after turning CSRF on. And resource requests: the paths /jakarta.faces.resource/** serve CSS, scripts and images and must be allowed for the login page to render, or the login screen appears unstyled. The mechanics of the filter chain are in the Spring Security filter chain. The Faces-specific rules for authentication, authorisation in EL and cookies are in the Jakarta Security post, securing a JSF application, with the container-managed parts replaced by Spring's.
Data and transactions
Services carry @Transactional, as in any Spring application, and the Faces beans call them. The interaction to understand is lazy loading. A Faces page reads entity associations during rendering, long after the service method returned and its transaction ended. With Spring Boot's open-in-view enabled (the default for web applications), the EntityManager stays open for the whole request, including rendering, so lazy loads in the page work and hide extra queries; with it disabled, the page throws LazyInitializationException, as described in the lazy initialisation fix. Prefer to load what the page needs in the service, into a view model or DTO, and turn open-in-view off, so the queries happen where you can see and count them. For JPA transaction scope in Faces beans themselves, JSF with JPA covers the patterns.
Packaging
An executable jar with the embedded Tomcat is the normal output, run with java -jar. Faces needs a few things at run time that the starters set: the Faces servlet mapping, the jakarta.faces.PROJECT_STAGE context parameter, the Facelets configuration. Set them with joinfaces.faces.* properties or application.properties; avoid a web.xml unless you need one. Development is smoother with Boot DevTools and the project stage Development, which shows detailed error pages; set Production in deployed profiles. Build time is not affected by Faces, and startup is slower than a plain Boot application because of the Faces initialisation and component scanning, typically a few seconds more.
Where this does not apply
If you are starting a new application with no Faces investment, weigh the alternatives first: a server-rendered stack with Thymeleaf and htmx, or a Java-based UI like Vaadin, compared in Vaadin versus htmx and Thymeleaf. JoinFaces keeps JSF usable on Boot; it does not make JSF the best choice for new work. Boot's own servlet support is described in the Spring Boot servlet reference, and the integration in the JoinFaces documentation.


