Spring Boot JSF Integration
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
Spring Boot and JSF can work together, but the integration is not as automatic as a typical Spring MVC application. JSF is a component-based servlet framework, so the main job is wiring the FacesServlet, Facelets pages, and bean resolution into Boot’s embedded servlet container.
Understand the Architecture First
JSF is not a replacement for Spring Boot. Boot gives you packaging, dependency management, auto-configuration, and the embedded servlet container. JSF handles the server-rendered UI layer.
That means a typical integrated app looks like this:
- Spring Boot starts the application
- the embedded servlet container hosts JSF
- JSF renders
.xhtmlpages - Spring beans provide services and business logic
This setup makes sense when you already want a JSF server-side component model. If you are building a REST API or a reactive UI backend, JSF is usually the wrong tool.
Add the Required Dependencies
At minimum you need the Boot web starter and a JSF implementation. With Spring Boot 3 style applications, use Jakarta packages rather than the older javax names.
Many teams use a starter such as JoinFaces to reduce boilerplate. The manual setup below is useful because it makes the moving parts explicit.
Register the FacesServlet
Boot does not expose JSF pages until the JSF servlet is registered.
This tells Boot to serve JSF requests through FacesServlet for .xhtml pages.
Expose Spring Beans to JSF EL
JSF pages commonly access beans through expression language such as #{greetingBean}. To resolve Spring-managed beans that way, add a JSF EL resolver in faces-config.xml.
Then define a Spring bean:
Create a Facelets Page
A minimal src/main/webapp/index.xhtml can render and bind to that bean:
At that point, Boot is hosting a JSF page backed by a Spring-managed bean.
Practical Constraints
There are a few rules that keep this sane:
- stay on the servlet stack, not WebFlux
- prefer
jakarta.*APIs in modern Spring Boot applications - keep your service layer in ordinary Spring beans
- treat JSF as the view layer, not as the whole application architecture
This matters because JSF integration becomes messy when you blur framework responsibilities.
Common Pitfalls
The biggest mistake is forgetting that JSF needs a servlet registration. Adding the dependency alone does not make .xhtml pages start working.
Another mistake is mixing old javax.faces era examples into a Jakarta-based Boot application. The package names and compatibility story changed.
Developers also often forget EL resolution for Spring beans, which leads to pages failing to resolve #{...} expressions even though the Spring bean exists.
Finally, JSF is not a good fit for every Boot project. If the app is mostly JSON APIs or modern front-end integration, Spring MVC controllers or REST endpoints are usually a better choice than forcing JSF into the stack.
Summary
- Spring Boot can host JSF, but the integration requires explicit servlet and bean-resolution setup.
- In modern applications, use Jakarta JSF packages rather than old
javaxexamples. - Register
FacesServlet, configurefaces-config.xml, and expose Spring beans through an EL resolver. - Keep Spring services as normal Spring beans and let JSF handle only the UI layer.
- Use this integration when you genuinely want server-rendered JSF pages, not as a default web stack choice.
Related reading
- Spring Boot JSP 404
- Spring boot Kafka class deserialization - not in the trusted package
- Spring Boot Kafka Commit cannot be completed since the group has already rebalanced
- Spring Boot Kafka Configure DefaultErrorHandler?
- Spring Boot Kafka health indicator
- Spring Boot Kafka Listener vs Consumer
- Spring Boot Kafka Startup error Connection to node -1 could not be established. Broker may not be available.
- Spring Boot Kafka Unable to start consumer due to NoSuchBeanDefinitionException

OOD Fundamentals
Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.