https://github.com/eclipse-ee4j/mojarra
Mojarra, a Jakarta Faces implementation
https://github.com/eclipse-ee4j/mojarra
Last synced: 2 months ago
JSON representation
Mojarra, a Jakarta Faces implementation
- Host: GitHub
- URL: https://github.com/eclipse-ee4j/mojarra
- Owner: eclipse-ee4j
- License: other
- Created: 2018-04-12T13:53:46.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2026-01-11T18:53:09.000Z (2 months ago)
- Last Synced: 2026-01-11T22:16:28.297Z (2 months ago)
- Language: Java
- Homepage:
- Size: 16.2 MB
- Stars: 178
- Watchers: 31
- Forks: 125
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Notice: NOTICE.md
Awesome Lists containing this project
- awesome-java - Eclipse Mojarra
README
# Mojarra 5.0
Eclipse's implementation of the Jakarta Faces 5.0 specification
* Mojarra 5.0 - this branch, under development
* [Mojarra 4.1](https://github.com/eclipse-ee4j/mojarra/blob/4.1/README.md) - stable release
* [Mojarra 4.0](https://github.com/eclipse-ee4j/mojarra/blob/4.0/README.md) - stable release
* [Mojarra 3.0](https://github.com/eclipse-ee4j/mojarra/blob/3.0/README.md) - legacy release
* [Mojarra 2.3](https://github.com/eclipse-ee4j/mojarra/blob/2.3/README.md) - legacy release
For support on Mojarra 2.3 and earlier please contact your vendor for support (RedHat, IBM,
Oracle, Omnifish, Payara, etceteras)
## Minimum Requirements
- Java 17
- Jakarta Servlet 6.1
- Jakarta Expression Language 6.0
- Jakarta CDI 4.1
- Jakarta Web Socket 2.2 (optional, only when `` is used)
- Jakarta JSON Processing 2.1 (optional, only when `` is used)
- Jakarta Validation 3.1 (optional, only when `` or `` is used)
## Installation
Depending on the server used, Jakarta Faces may already be built-in (full fledged Jakarta EE containers such as [WildFly][1], [JBoss EAP][2], [TomEE][3], [Payara][4], [GlassFish][5], [Liberty][6], etc.), or not (barebones Jakarta Server Pages/Jakarta Servlet containers such as [Tomcat][7], [Jetty][8], etc.). If the server doesn't ship with Jakarta Faces built-in, then you need to manually install Jakarta Faces 4.0 along with CDI 4.0+, Jakarta JSON Processing 2.0+ and Jakarta Standard Tag Library 2.0+ as those Jakarta Servlet containers usually also don't even ship with those Jakarta Faces dependencies.
### Non-Maven
In case you're manually carrying around JARs:
- **Jakarta EE containers (WildFly, JBoss EAP, TomEE, Payara, GlassFish, Liberty, etc)**
You don't need to add any JARs to `/WEB-INF/lib`!
- **Jakarta Servlet containers (Tomcat, Jetty, etc)**
Add below JARs to `/WEB-INF/lib`:
- [`jakarta.faces.4.1.x.jar`][9]
- [`weld-servlet-shaded-4.1.0.Final.jar`][10]
- [`jakarta.json-api-2.1.0.jar`][12] (optional, only when `` is used)
- [`jakarta.json-2.1.0.jar`][12a] (optional, only when `` is used)
- [`jakarta.validation-api-3.1.0.jar`][13] (optional, only when `` is used)
- [`hibernate-validator-8.0.x.Final.jar`][14] (optional, only when `` is used)
Substitute `x` with latest version number available.
### Maven
In case you're using Maven, you can find below the necessary coordinates:
- **Java EE containers (WildFly, JBoss EAP, TomEE, Payara, GlassFish, Liberty, etc)**
```xml
jakarta.platform
jakarta.jakartaee-api
11.0.0
provided
```
In case of WildFly/JBoss EAP, [you need to manually package `jsf-api.jar` and `jsf-impl.jar` based on `jakarta.faces.jar` first][15]. In case of TomEE, just swap the `myfaces*.jar` files with `jakarta.faces.jar` in the server's `/lib` folder. In case of Payara/GlassFish, just swap the `jakarta.faces.jar` file in the server's `/glassfish/modules` folder.
- **Servletcontainers (Tomcat, Jetty, etc)**
```xml
org.glassfish
jakarta.faces
org.jboss.weld.servlet
weld-servlet-shaded
4.1.0.Final
org.glassfish
jakarta.json
2.1.0
org.hibernate.validator
hibernate-validator
```
You can check [`org.glassfish:jakarta.faces`][16] repository to find the latest Mojarra 4.0.x version.
## Testing
Since Mojarra 4, tests have been moved to the [Faces project](https://github.com/jakartaee/faces/tree/master/tck).
## Hello World Example
We assume that you already know how to create an empty Maven WAR Project or Dynamic Web Project in your favourite IDE with a CDI 4.0+ compatible `/WEB-INF/beans.xml` deployment descriptor file (which can be kept fully empty). Don't forget to add JARs or configure pom.xml if necessary, as instructed in previous chapter.
### Controller
Optionally, register the `FacesServlet` in a Servlet 6.0+ compatible deployment descriptor file `/WEB-INF/web.xml` as below:
```xml
facesServlet
jakarta.faces.webapp.FacesServlet
facesServlet
*.xhtml
```
Noted should be that Jakarta Faces is already "implicitly" registered and mapped on `*.xhtml`, `*.jsf`, `*.faces` and `/faces/*` when running on a Jakarta Servlet container. This will be overridden altogether when explicitly registering as above. [The `*.xhtml` URL pattern is preferred over above for security and clarity reasons][17]. When you don't explicitly map it on `*.xhtml`, then people can still access Faces pages using `*.jsf`, `*.faces` or `/faces/*` URL patterns. This is not nice for SEO as Faces by design doesn't 301-redirect them to a single mapping.
The Faces deployment descriptor file `/WEB-INF/faces-config.xml` is fully optional.
```xml
```
### Model
Then create a backing bean class as below:
```java
package com.example;
import jakarta.enterprise.context.RequestScoped;
import jakarta.inject.Named;
@Named
@RequestScoped
public class Hello {
private String name;
private String message;
public void createMessage() {
message = "Hello, " + name + "!";
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getMessage() {
return message;
}
}
```
Noted should be that in reality in the average Jakarta EE application the above "model" is further breakdown into a Jakarta Persistence entity, a Jakarta Enterprise Beans service and a smaller backing bean. The Jakarta Persistence entity and Jakarta Enterprise Beans service then basically act as a true "model" and the backing bean becomes a "controller" for that model. This may in first place be confusing to starters, but it all depends on the point of view. See also [What components are MVC in Faces MVC framework?][18] and [Faces Controller, Service and DAO][19].
### View
Finally create a [Facelets][20] file `/hello.xhtml` as below:
```xml
Hello, World!
#{hello.message}
```
Start the server and open it by `http://localhost:8080/contextname/hello.xhtml`.
## Activating CDI in Jakarta Faces 4.1
CDI is activated by default in Jakarta Faces 4.1 and can´t be deactivated.
It´s not required anymore to add `@FacesConfig` to a CDI managed bean to accomplish this.
As of Jakarta Faces 4.0 `@FacesConfig` still removes the need to explicitly add a `FacesServlet` entry to `web.xml`.
## Building
In case you want to checkout this repository and manually build from source yourself (if necessary after editing source code), here are the instructions:
### Jakarta Faces.Next
1. Make sure that you have JDK 17, Ant and Maven installed.
2. Checkout branch [`master`][28].
3. Run the following commands from the root directory of the project:
```bash
# under the root dir of project
mvn clean install
```
4. The binary is now available as `impl/target/jakarta.faces-4.x.x-SNAPSHOT.jar`.
### Jakarta Faces 4.0
1. Make sure that you have JDK 11, Ant and Maven installed.
2. Checkout branch [`4.0`][31].
3. Run the following commands from the root directory of the project:
```bash
# under the root dir of project
mvn clean install
```
4. The binary is now available as `impl/target/jakarta.faces-4.0.x-SNAPSHOT.jar`.
### Jakarta Faces 3.0
1. Make sure that you have JDK 1.8, Ant and Maven installed.
2. Checkout branch [`3.0`][29].
3. Run the following commands from the root directory of the project:
```bash
# under the root dir of project
mvn clean install
```
4. The binary is now available as `impl/target/jakarta.faces-3.0.x-SNAPSHOT.jar`.
### Jakarta Faces 2.3
1. Make sure that you have JDK 1.8, Ant and Maven installed.
2. Checkout branch [`2.3`][30].
3. Run the following commands from the root directory of the project:
```bash
# under the root dir of project
mvn clean install
```
4. The binary is now available as `impl/target/jakarta.faces-2.3.x-SNAPSHOT.jar`.
### Jakarta Faces 2.2
Jakarta Faces 2.2 and lower are not supported by Eclipse. If such support is needed, consult your Jakara EE vendor of choice.
## Editing source code with IDE
In case you want to checkout to edit the source code of Mojarra with full IDE support, here are the instructions. Note that this only allows you to *edit* the code. Actually building the Mojarra artefacts still has to be done using the instructions provided above.
### Eclipse
#### Jakarta Faces 4.0
1. Checkout branch [`4.0`][29] using File -> import -> Git
2. Right click the Mojarra project after checkout, choose Configure -> Convert to Maven Project
#### Jakarta Faces 3.0
1. Checkout branch [`3.0`][29] using File -> import -> Git
2. Right click the Mojarra project after checkout, choose Configure -> Convert to Maven Project
#### Jakarta Faces 2.3
1. Checkout branch [`2.3`][30] using File -> import -> Git
2. Right click the Mojarra project after checkout, choose Configure -> Convert to Maven Project
## Pull Requests
Pull requests are accepted on following branches:
- [`master`][28] (4.0.x)
- [`3.0`][29] (3.0.x)
- [`2.3`][30] (2.3.x)
Note that it's okay to send a PR to the master branch, but this one is for Faces.next and not the current 2.3.x or 3.0.x version.
## Releasing
pom.xml versions can be adjusted as follows
```
mvn versions:set -DgroupId=* -DartifactId=* -DoldVersion=* -DgenerateBackupPoms=false -DnewVersion=4.0.1-SNAPSHOT
```
## Resources
- [JSF 2.3 Specification (JSR 372)][21]
- [JSF 2.3 API documentation][22]
- [JSF 2.3 VDL documentation][23]
- [JSF 2.3 JS documentation][24]
- [Oracle Java EE 7 tutorial - JavaServer Faces Technology][25] (currently still JSF 2.2)
- [What's new in JSF 2.3?][26]
- [Java EE Kickoff Application][27]
[1]: http://wildfly.org/
[2]: https://developers.redhat.com/products/eap/overview/
[3]: http://tomee.apache.org
[4]: http://www.payara.fish
[5]: https://javaee.github.io/glassfish/
[6]: https://developer.ibm.com/wasdev/websphere-liberty/
[7]: http://tomcat.apache.org
[8]: http://www.eclipse.org/jetty/
[9]: https://repo1.maven.org/maven2/org/glassfish/jakarta.faces/
[10]: https://repo1.maven.org/maven2/org/jboss/weld/servlet/weld-servlet-shaded/
[11]: https://repo.maven.apache.org/maven2/jakarta/servlet/jsp/jstl/jakarta.servlet.jsp.jstl-api
[12]: https://repo1.maven.org/maven2/jakarta/json/jakarta.json-api
[12A]: https://repo1.maven.org/maven2/org/glassfish/jakarta.json/
[13]: https://repo1.maven.org/maven2/jakarta/validation/jakarta.validation-api
[14]: https://repo1.maven.org/maven2/org/hibernate/validator/hibernate-validator
[15]: https://stackoverflow.com/q/35899887/157882
[16]: http://mvnrepository.com/artifact/org.glassfish/jakarta.faces
[17]: https://stackoverflow.com/q/3008395/157882
[18]: https://stackoverflow.com/q/5104094/157882
[19]: https://stackoverflow.com/q/30639785/157882
[20]: http://docs.oracle.com/javaee/7/tutorial/jsf-facelets.htm
[21]: http://download.oracle.com/otn-pub/jcp/jsf-2_3-final-eval-spec/JSF_2.3.pdf
[22]: https://javaserverfaces.github.io/docs/2.3/javadocs/index.html
[23]: https://javaserverfaces.github.io/docs/2.3/vdldoc/index.html
[24]: https://javaserverfaces.github.io/docs/2.3/jsdocs/index.html
[25]: http://docs.oracle.com/javaee/7/tutorial/jsf-intro.htm
[26]: http://arjan-tijms.omnifaces.org/p/jsf-23.html
[27]: https://github.com/javaeekickoff/java-ee-kickoff-app
[28]: https://github.com/eclipse-ee4j/mojarra
[29]: https://github.com/eclipse-ee4j/mojarra/tree/3.0
[30]: https://github.com/eclipse-ee4j/mojarra/tree/2.3
[31]: https://github.com/eclipse-ee4j/mojarra/tree/4.0