Recent from talks
Contribute something
Nothing was collected or created yet.
Jakarta EE
View on Wikipedia| Player software | Java |
|---|---|
| Programming language(s) | Java |
| Application(s) | Application server |
| Status | Active |
| License | Eclipse Public License or GNU General Public License w/Classpath exception |
| Website | jakarta |
| Java platform editions |
|---|
|
Jakarta EE, formerly Java Platform, Enterprise Edition (Java EE) and Java 2 Platform, Enterprise Edition (J2EE), is a set of specifications, extending Java SE[1] with specifications for enterprise features such as distributed computing and web services.[2] Jakarta EE applications are run on reference runtimes, which can be microservices or application servers, which handle transactions, security, scalability, concurrency and management of the components they are deploying.
Jakarta EE is defined by its specification. The specification defines APIs (application programming interface) and their interactions. As with other Java Community Process specifications, providers must meet certain conformance requirements in order to declare their products as Jakarta EE compliant.
Examples of contexts in which Jakarta EE referencing runtimes are used are: e-commerce, accounting, banking information systems.
History
[edit]The platform created by Sun Microsystems was known as Java 2 Platform, Enterprise Edition or J2EE from version 1.2, until the name was changed to Java Platform, Enterprise Edition or Java EE in version 1.5.
After Sun was acquired in 2009, Java EE was maintained by Oracle under the Java Community Process. On September 12, 2017, Oracle Corporation announced that it would submit Java EE to the Eclipse Foundation.[3] The Eclipse top-level project has been named Eclipse Enterprise for Java (EE4J).[4] The Eclipse Foundation could not agree with Oracle over the use of javax and Java trademarks.[5] Oracle owns the trademark for the name "Java" and the platform was renamed from Java EE to Jakarta EE.[6][7] The name refers to the largest city on the island of Java and also the capital of Indonesia, Jakarta.[8] The name should not be confused with the former Jakarta Project which fostered a number of current and former Java projects at the Apache Software Foundation.
| Platform version | Release[9] | Specification | Java SE Support | Important Changes |
|---|---|---|---|---|
| Jakarta EE 11 | Planned for June/July 2024 | 11 | Java SE 21 | Data |
| Jakarta EE 10 | 2022-09-22[10] | 10 |
|
Removal of deprecated items in Servlet, Faces, CDI and EJB (Entity Beans and Embeddable Container). CDI-Build Time. |
| Jakarta EE 9.1 | 2021-05-25[11] | 9.1 |
|
JDK 11 support |
| Jakarta EE 9 | 2020-12-08[12] | 9 | Java SE 8 | API namespace move from javax to jakarta
|
| Jakarta EE 8 | 2019-09-10[13] | 8 | Java SE 8 | Full compatibility with Java EE 8 |
| Java EE 8 | 2017-08-31 | JSR 366 | Java SE 8 | HTTP/2 and CDI based Security |
| Java EE 7 | 2013-05-28 | JSR 342 | Java SE 7 | WebSocket, JSON and HTML5 support |
| Java EE 6 | 2009-12-10 | JSR 316 | Java SE 6 | CDI managed Beans and REST |
| Java EE 5 | 2006-05-11 | JSR 244 | Java SE 5 | Java annotations and Generics in Java |
| J2EE 1.4 | 2003-11-11 | JSR 151 | J2SE 1.4 | WS-I interoperable web services[14] |
| J2EE 1.3 | 2001-09-24 | JSR 58 | J2SE 1.3 | Java connector architecture[15] |
| J2EE 1.2 | 1999-12-17 | 1.2 | J2SE 1.2 | Initial specification release |
Specifications
[edit]Jakarta EE includes several specifications that serve different purposes, like generating web pages, reading and writing from a database in a transactional way, and managing distributed queues.
The Jakarta EE APIs include several technologies that extend the functionality of the base Java SE APIs, such as Jakarta Enterprise Beans, connectors, servlets, Jakarta Server Pages and several web service technologies.
Web specifications
[edit]- Jakarta Servlet: defines how to manage HTTP requests, in a synchronous or asynchronous way. It is low level and other Jakarta EE specifications rely on it;
- Jakarta WebSocket: API specification that defines a set of APIs to service WebSocket connections;
- Jakarta Faces: a technology for constructing user interfaces out of components;
- Jakarta Expression Language (EL) is a simple language originally designed to satisfy the specific needs of web application developers. It is used specifically in Jakarta Faces to bind components to (backing) beans and in Contexts and Dependency Injection to named beans, but can be used throughout the entire platform.
Web service specifications
[edit]- Jakarta RESTful Web Services provides support in creating web services according to the Representational State Transfer (REST) architectural pattern;
- Jakarta JSON Processing is a set of specifications to manage information encoded in JSON format;
- Jakarta JSON Binding provides specifications to convert JSON information into or from Java classes;
- Jakarta XML Binding allows mapping XML into Java objects;
- Jakarta XML Web Services can be used to create SOAP web services.
Enterprise specifications
[edit]- Jakarta Activation (JAF) specifies an architecture to extend component Beans by providing data typing and bindings of such types.
- Jakarta Contexts and Dependency Injection (CDI) is a specification to provide a dependency injection container;
- Jakarta Enterprise Beans (EJB) specification defines a set of lightweight APIs that an object container (the EJB container) will support in order to provide transactions (using JTA), remote procedure calls (using RMI or RMI-IIOP), concurrency control, dependency injection and access control for business objects. This package contains the Jakarta Enterprise Beans classes and interfaces that define the contracts between the enterprise bean and its clients and between the enterprise bean and the ejb container.
- Jakarta Persistence (JPA) are specifications about object-relational mapping between relation database tables and Java classes.
- Jakarta Transactions (JTA) contains the interfaces and annotations to interact with the transaction support offered by Jakarta EE. Even though this API abstracts from the really low-level details, the interfaces are also considered somewhat low-level and the average application developer in Jakarta EE is either assumed to be relying on transparent handling of transactions by the higher level EJB abstractions, or using the annotations provided by this API in combination with CDI managed beans.
- Jakarta Messaging (JMS) provides a common way for Java programs to create, send, receive and read an enterprise messaging system's messages.
Other specifications
[edit]- Jakarta Validation: This package contains the annotations and interfaces for the declarative validation support offered by the Jakarta Validation API. Jakarta Validation provides a unified way to provide constraints on beans (e.g. Jakarta Persistence model classes) that can be enforced cross-layer. In Jakarta EE, Jakarta Persistence honors bean validation constraints in the persistence layer, while JSF does so in the view layer.
- Jakarta Batch provides the means for batch processing in applications to run long running background tasks that possibly involve a large volume of data and which may need to be periodically executed.
- Jakarta Connectors is a Java-based tool for connecting application servers and enterprise information systems (EIS) as part of enterprise application integration (EAI). This is a low-level API aimed at vendors that the average application developer typically does not come in contact with.
Web profile
[edit]In an attempt to limit the footprint of web containers, both in physical and in conceptual terms, the web profile was created, a subset of the Jakarta EE specifications. The Jakarta EE web profile comprises the following:
| Specification | Java EE 6[16] | Java EE 7[17] | Java EE 8[18] Jakarta EE 8[19] |
Jakarta EE 9[20] Jakarta EE 9.1[21] |
Jakarta EE 10[22] | Jakarta EE 11 |
|---|---|---|---|---|---|---|
| Jakarta Servlet | 3.0 | 3.1 | 4.0 | 5.0 | 6.0 | 6.1 |
| Jakarta Server Pages (JSP) | 2.2 | 2.3 | 2.3 | 3.0 | 3.1 | 4.0 |
| Jakarta Expression Language (EL) | 2.2 | 3.0 | 3.0 | 4.0 | 5.0 | 6.0 |
| Jakarta Debugging Support for Other Languages (JSR-45) | 1.0 | 1.0 | 1.0 | 2.0 | 2.0 | 2.0 |
| Jakarta Standard Tag Library (JSTL) | 1.2 | 1.2 | 1.2 | 2.0 | 3.0 | 3.0 |
| Jakarta Faces | 2.0 | 2.2 | 2.3 | 3.0 | 4.0 | 4.1 |
| Jakarta RESTful Web Services (JAX-RS) | 1.1 | 2.0 | 2.1 | 3.0 | 3.1 | 4.0 |
| Jakarta WebSocket (WebSocket) | — | 1.0 | 1.1 | 2.0 | 2.1 | 2.2 |
| Jakarta JSON Processing (JSON-P) | — | 1.0 | 1.1 | 2.0 | 2.1 | 2.1 |
| Jakarta JSON Binding (JSON-B) | — | — | 1.1 | 2.0 | 3.0 | 3.0 |
| Jakarta Annotations (CA) | 1.1 | 1.2 | 1.3 | 2.0 | 2.1 | 3.0 |
| Jakarta Enterprise Beans (EJB) | 3.1 Lite | 3.2 Lite | 3.2 Lite | 4.0 Lite | 4.0 Lite | 4.0 Lite |
| Jakarta Transactions (JTA) | 1.1 | 1.2 | 1.2 | 2.0 | 2.0 | 2.0 |
| Jakarta Persistence (JPA) | 2.0 | 2.1 | 2.2 | 3.0 | 3.1 | 3.2 |
| Jakarta Bean Validation | 1.0 | 1.1 | 2.0 | 3.0 | 3.0 | 3.1 |
| Jakarta Managed Beans | 1.0 | 1.0 | 1.0 | 2.0 | — | N/a |
| Jakarta Interceptors | 1.1 | 1.2 | 1.2 | 2.0 | 2.1 | 2.2 |
| Jakarta Contexts and Dependency Injection (CDI) | 1.0 | 1.1 | 2.0 | 3.0 | 4.0 | 4.1 |
| Jakarta Dependency Injection | 1.0 | 1.0 | 1.0 | 2.0 | 2.0 | 2.0 |
| Jakarta Security | — | — | 1.0 | 2.0 | 3.0 | 4.0 |
| Jakarta Authentication | — | 1.0 | 1.1 | 2.0 | 3.0 | 3.1 |
| Jakarta Concurrency | — | — | — | — | 3.0 | 3.1 |
Certified referencing runtimes
[edit]Although by definition all Jakarta EE implementations provide the same base level of technologies (namely, the Jakarta EE spec and the associated APIs), they can differ considerably with respect to extra features (like connectors, clustering, fault tolerance, high availability, security, etc.), installed size, memory footprint, startup time, etc.
Jakarta EE
[edit]| Referencing runtime[23][24][25] | Developer | Jakarta EE 10 Platform | Jakarta EE 9/9.1 Platform Compatible Products | Jakarta EE 9/9.1 Web Profile Compatible Products | Jakarta EE 8 Platform Compatible Products | Jakarta EE 8 Web Profile Compatible Products | Licensing |
|---|---|---|---|---|---|---|---|
| GlassFish | Eclipse | Yes 7.0.0 | Yes 6.0.0/ 6.1.0 | Yes 6.0.0/ 6.1.0 | Yes 5.1.0 | Yes 5.1.0 | Free software |
| Open Liberty | IBM | Yes 22.0.0.13-beta,[26] 23.0.0.3[27] | Yes 21.0.0.12 | Yes 21.0.0.12 | Yes 19.0.0.6, 20.0.0.3 | Yes 19.0.0.6, 20.0.0.3 | Free software |
| WebSphere Liberty | IBM | Yes 23.0.0.3[27] | Yes 21.0.0.12 | Yes 21.0.0.12 | Yes 20.0.0.3 | Yes 20.0.0.3 | Proprietary software |
| WildFly | Red Hat | Yes 27.0.0.Alpha5 | Yes 23.0.1-Preview/25.0.0-Preview | Yes 23.0.1-Preview/25.0.0-Preview | Yes 18.0.0 | Yes 18.0.0 | Free software |
| JBoss EAP | Red Hat | Yes 8.0.0 | No | No | Yes 7.3.0 | Yes 7.3.0 | Free software |
| TomEE | Apache | Yes 10.x | Yes 9.x | Yes 9.x | Yes 8.x | Yes 8.x | Free software |
| Payara Server | Payara Services Limited | Yes 6.2022.1 Alpha 4 | Yes 6.2021.1 Alpha 1 | No | Yes 5.22.0, 5.23.0 | Yes 5.23.0 | Free software |
| Thunisoft Application Server | Beijing Thunisoft Information Technology | No | Yes 3.0 | No | Yes 2.8 | No | Proprietary software |
| JEUS | TmaxSoft | No | No | No | Yes 8.5 | No | Proprietary software |
| InforSuite Application Server | Shandong Cvicse Middleware | No | Yes 11 | No | Yes 10 | No | Proprietary software |
| WebOTX | NEC | Yes 12 | No | No | Yes 11 | No | Proprietary software |
Java EE
[edit]| Referencing runtime | Developer | Java EE 8 certified – Full | Java EE 8 certified – Web | Java EE 7 certified – Full | Java EE 7 certified – Web | Java EE 6 certified – Full Official Oracle page for Java EE Compatibility. |
Java EE 6 certified – Web | Java EE 5 certified | J2EE 1.4 certified | Licensing |
|---|---|---|---|---|---|---|---|---|---|---|
| GlassFish server Open Source Edition | Oracle | Yes v5.0[28] | Yes v5.0[28] | Yes v4.x[29] | Yes v4.x[29] | Yes v3.x and upward[30] | Yes v3.x Web Profile | Yes v2.1.x[30] | Free software | |
| Oracle GlassFish Server | Oracle | Yes v3[31] based on the open source GlassFish application server | Yes Sun Java System Application Server v9.0 | Yes Sun Java System Application Server v8.2 | Proprietary software | |||||
| Oracle WebLogic Server | Oracle | Yes 14.1.1[32] | Yes 12.2.1[33] | Yes v12c[34] | Yes v10.3.5.0 | Yes v9 | Proprietary software | |||
| WildFly | Red Hat | Yes v14.x[28] | Yes v14.x[28] | Yes v8.1 [35] | Yes v8.0.0.Final | Yes v7.1[36] | Yes v6.0[37] and v7.0[38] | Yes v5.1[39][40] | Yes v4.x | Free software |
| JBoss Enterprise Application Platform | Red Hat | Yes v7.2 [41] | Yes v7.0[29] | Yes v7.0[29] | Yes v6.0[42] | Yes v5 | Proprietary software | |||
| IBM WebSphere Application Server | IBM | Yes v9.x[28] | Yes v9.x[29] | Yes v8[43] | Yes v7 | Yes | Proprietary software | |||
| IBM WebSphere Application Server Liberty | IBM | Yes v18.0.0.2[44] | Yes v18.0.0.2[44] | Yes v8.5.5.6[45][46] | Yes v8.5.5.6[29] | Yes v8.5.5[47] | Proprietary software | |||
| Open Liberty | IBM | Yes v18.0.0.2 | Yes v18.0.0.2 | Free software | ||||||
| IBM WebSphere Application Server Community Edition | IBM | Yes v3.0 | Yes v2.1 | Proprietary software | ||||||
| Apache Geronimo | Apache | Yes v3.0-beta-1[48][49] | Yes v2.0 | Yes v1.0 | Free software | |||||
| JEUS | TmaxSoft | Yes v8 | Yes v7[50][51] | Yes v6 | Yes v5 | Proprietary software | ||||
| Cosminexus Application Server | Hitachi | Yes v10.0[28] | Yes v9[52] | Proprietary software | ||||||
| Fujitsu Interstage Application Server[53] | Fujitsu | Yes v12.0[28] | Yes v1 Azure/v10.1[54][55] | Yes | Proprietary software | |||||
| WebOTX | NEC | Yes[56] | Yes | Proprietary software | ||||||
| BES Application Server | Baolande | Yes v9.5[29] | ||||||||
| Apache TomEE[57][58] | Apache | No 7 (Java EE 7 like, but not certified[59]) | Yes | Free software | ||||||
| Resin Server | Caucho | Yes v4.0[60] | Yes | Proprietary software | ||||||
| Siwpas | OW2 | Yes v6.0[61] | Free software | |||||||
| JOnAS | OW2 | Yes v5.3 rc1[62] | Yes | Yes | Free software | |||||
| SAP NetWeaver | SAP | Yes v2.x[63] | Yes | Yes | Proprietary software | |||||
| Oracle Containers for Java EE | Oracle | Yes | Proprietary software | |||||||
| Oracle iPlanet Web Server | Oracle | Yes Sun Java System Web Server | Proprietary software | |||||||
| Oracle Application Server 10g | Oracle | Yes | Proprietary software | |||||||
| Pramati Server | Pramati Technologies | Yes v5.0 | Proprietary software | |||||||
| Trifork T4 | Trifork | Yes | Proprietary software | |||||||
| Sybase Enterprise Application Server[64] | Sybase | Yes | Proprietary software |
Code sample
[edit]The code sample shown below demonstrates how various technologies in Java EE 7 are used together to build a web form for editing a user.
In Jakarta EE a (web) UI can be built using Jakarta Servlet, Jakarta Server Pages (JSP), or Jakarta Faces (JSF) with Facelets. The example below uses Faces and Facelets. Not explicitly shown is that the input components use the Jakarta EE Bean Validation API under the covers to validate constraints.
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:f="http://xmlns.jcp.org/jsf/core">
<f:metadata>
<f:viewParam name="user_id" value="#{userEdit.user}" converter="#{userConvertor}" />
</f:metadata>
<h:body>
<h:messages />
<h:form>
<h:panelGrid columns="2">
<h:outputLabel for="firstName" value="First name" />
<h:inputText id="firstName" value="#{userEdit.user.firstName}" label="First name" />
<h:outputLabel for="lastName" value="Last name" />
<h:inputText id="lastName" value="#{userEdit.user.lastName}" label="Last name" />
<h:commandButton action="#{userEdit.saveUser}" value="Save" />
</h:panelGrid>
</h:form>
</h:body>
</html>
Example Backing Bean class
[edit]To assist the view, Jakarta EE uses a concept called a "Backing Bean". The example below uses Contexts and Dependency Injection (CDI) and Jakarta Enterprise Beans (EJB).
import java.io.Serializable;
import jakarta.inject.Named;
import jakarta.faces.view.ViewScoped;
import jakarta.inject.Inject;
@Named
@ViewScoped
public class UserEdit implements Serializable {
private static final long serialVersionUID = 1L;
private User user;
@Inject
private UserDAO userDAO;
public String saveUser() {
userDAO.save(this.user);
addFlashMessage(String.format("User %d saved", this.user.getId()));
return "users.xhtml?faces-redirect=true";
}
public void setUser(User user) {
this.user = user;
}
public User getUser() {
return user;
}
}
Example Data Access Object class
[edit]To implement business logic, Jakarta Enterprise Beans (EJB) is the dedicated technology in Jakarta EE. For the actual persistence, JDBC or Jakarta Persistence (JPA) can be used. The example below uses EJB and JPA. Not explicitly shown is that JTA is used under the covers by EJB to control transactional behavior.
import java.util.List;
import jakarta.ejb.Stateless;
import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
import jakarta.persistence.TypedQuery;
@Stateless
public class UserDAO {
@PersistenceContext
private EntityManager entityManager;
public void save(User user) {
entityManager.persist(user);
}
public void update(User user) {
entityManager.merge(user);
}
public List<User> getAll() {
return entityManager.createNamedQuery("User.getAll", User.class)
.getResultList();
}
}
Example Entity class
[edit]For defining entity/model classes Jakarta EE provides the Jakarta Persistence (JPA), and for expressing constraints on those entities it provides the Bean Validation API. The example below uses both these technologies.
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
@Entity
public class User {
@Id
@GeneratedValue(strategy = IDENTITY)
private Integer id;
@Size(min = 2, message="First name too short")
private String firstName;
@Size(min = 2, message="Last name too short")
private String lastName;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
}
See also
[edit]References
[edit]- ^ "Differences between Java EE and Java SE - Your First Cup: An Introduction to the Java EE Platform". Docs.oracle.com. 2012-04-01. Retrieved 2012-07-18.
- ^ "Java EE Overview". Oracle Corporation. Retrieved February 26, 2017.
- ^ Waters, John K. (September 12, 2017). "Java EE Is Moving to the Eclipse Foundation". ADTmag. Retrieved 2017-09-13.
- ^ Beaton, Wayne. "EE4J FAQ". Eclipse Foundation.
- ^ Milinkovich, Mike (May 3, 2019). "Update on Jakarta EE Rights to Java Trademarks". Blog. Life at Eclipse. Retrieved 2024-07-25.
- ^ Chirgwin, Richard (March 4, 2018). "Java EE renamed 'Jakarta EE' after Big Red brand spat". Software. The Register. Retrieved 19 March 2018.
- ^ Vaughan-Nichols, Steven J. (March 5, 2018). "Good-bye JEE, hello Jakarta EE". Linux and Open Source. ZDNet. Retrieved 2020-07-10.
- ^ Tijms, Arjan (February 27, 2020). "Transition From Java EE to Jakarta EE". Java Magazine. blogs.oracle.com. Retrieved 2024-07-25.
- ^ "Jakarta EE Releases". Jakarta EE. Eclipse Foundation. Retrieved 2024-07-17.
- ^ Obradovic, Tanja; Grimstad, Ivar (2022-09-22). "The Eclipse Foundation's Jakarta EE Working Group Releases Jakarta EE 10 to Usher in the Era of Cloud Native Java". News. Jakarta EE (Press release). Eclipse Foundation. Retrieved 2024-07-17.
- ^ Obradovic, Tanja; Grimstad, Ivar (2021-05-25). "The Jakarta EE Working Group Releases Jakarta EE 9.1 as Industry Continues to Embrace Open Source Enterprise Java". News. Jakarta EE (Press release). Eclipse Foundation. Retrieved 2022-03-05.
- ^ Mmayel, Shabnam; Obradovic, Tanja (2020-12-08). "Jakarta EE 9 Released!". News. Jakarta EE (Press release). Eclipse Foundation. Retrieved 2022-03-05.
- ^ Mmayel, Shabnam; Obradovic, Tanja (2019-09-10). "Jakarta EE 8 Released!". News. Jakarta EE (Press release). Eclipse Foundation. Retrieved 2022-03-05.
- ^ Krill, Paul (November 21, 2003). "J2EE 1.4 spec certified". Software Development. InfoWorld. Retrieved 2022-03-05.
- ^ Copeland, Lee (September 24, 2001). "Sun unveils J2EE 1.3". Software Development. Computerworld. Retrieved 2022-03-05.
- ^ "JSR 316: Java Platform, Enterprise Edition 6 (Java EE 6) Specification". Java Community Process. Oracle Corporation. Retrieved 2022-03-05.
- ^ "JSR 342: Java Platform, Enterprise Edition 7 (Java EE 7) Specification". Java Community Process. Oracle Corporation. Retrieved 2022-03-05.
- ^ "Java Platform, Enterprise Edition 8 (Java EE 8) Web Profile Specification" (PDF). GitHub. Oracle Corporation. Archived (PDF) from the original on 2022-10-09. Retrieved 2022-02-05.
- ^ "Web Profile Definition". Jakarta EE WebProfile. 8. Jakarta EE. Eclipse Foundation. Retrieved 2022-03-05.
- ^ "Web Profile Definition". Jakarta EE WebProfile. 9. Jakarta EE. Eclipse Foundation. Retrieved 2022-03-05.
- ^ "Web Profile Definition". Jakarta EE WebProfile. 9.1. Jakarta EE. Eclipse Foundation. Retrieved 2022-03-05.
- ^ "Web Profile Definition". Jakarta EE WebProfile. 10. Jakarta EE. Eclipse Foundation. Retrieved 2022-09-27.
- ^ "Jakarta EE Compatible Products". Jakarta.ee.
- ^ "Jakarta EE 9 Compatible Products". Jakarta.ee.
- ^ "Jakarta EE 8 Compatible Products". Jakarta.ee.
- ^ "Jakarta EE 10 Platform and MicroProfile 6 in Open Liberty 23.0.0.1-beta". openliberty.io.
- ^ a b "Jakarta EE 10, MicroProfile 6, and Java SE 20 support in Open Liberty 23.0.0.3". openliberty.io.
- ^ a b c d e f g "Java EE Compatibility". www.oracle.com. Retrieved 2018-08-05.
- ^ a b c d e f g "Java EE Compatibility".
- ^ a b "Comparing GlassFish Open Source Edition versions 2.x and 3.0.x". Archived from the original on 2012-12-20.
- ^ "Java EE Compatibility". Java.sun.com. 2010-09-07. Retrieved 2012-07-18.
- ^ "Oracle Weblogic Server 14.1.1". www.oracle.com.
- ^ "Oracle Weblogic Server 12.1.1". www.oracle.com.
- ^ Lyons, Will; Humphrey, Pieter (2011). "Oracle Web Logic Server 12c: Developing Modern, Lightweight Java EE 6 Applications" (PDF). Archived from the original (PDF) on 2011-12-15. Retrieved 2011-12-03.
- ^ "Java EE Compatibility". www.oracle.com.
- ^ "JBoss AS 7.1.0.Final "Thunder" released - Java EE 6 Full Profile certified! | My Wiki | Planet JBoss Community". Planet.jboss.org. 2012-02-17. Retrieved 2012-07-18.
- ^ "JBoss Application Server - JBoss Community".
- ^ "JBoss Application Server - JBoss Community".
- ^ "Java EE Compatibility".
- ^ "JBoss AS is now EE5 certified!". 15 September 2008. Archived from the original on 20 September 2008. Retrieved 7 August 2016.
- ^ "Red Hat JBoss Enterprise Application Platform 7.2 Availability".
- ^ "Red Hat Launches JBoss Enterprise Application Platform 6 to Help Enterprises Move Application Development and Deployment to the Cloud". Business Wire. 2012-06-20. Archived from the original on 2016-11-11. Retrieved 2012-07-18.
- ^ "What's new in WebSphere Application Server V8". Ibm.com. Retrieved 2012-07-18.
- ^ a b "IBM WebSphere Application Server Liberty delivers the first production-ready, Java EE 8-compatible application server and broadens support for Spring Boot applications". IBM. 10 July 2018. Retrieved 12 July 2018.
- ^ "Java EE 7 - Tested Configurations- IBM WebSphere Application Server Liberty Profile". Oracle.com.
- ^ "Java EE 7 has landed in WAS Liberty - WASdev". 25 June 2015.
- ^ "IBM Java EE 6 Web Profile Tested Configurations".
- ^ "Apache Geronimo : Index". geronimo.apache.org. January 25, 2010.
- ^ "Apache Geronimo fully certified for Java EE 6 - The H Open: News and Features". H-online.com. 2011-11-14. Archived from the original on 20 April 2012. Retrieved 2012-07-18.
- ^ "Tested Configurations, Java EE 6 - TMAX JEUS 7". Oracle.com. 2010-09-07. Retrieved 2012-07-18.
- ^ "Java EE6 Web Application Server, WAS Software". Us.tmaxsoft.com. Archived from the original on 2012-07-02. Retrieved 2012-07-18.
- ^ "Java EE 6 - Tested Configurations, Java EE 6 - Hitachi uCosminexus Application Server v9.0". Oracle.com.
- ^ "Fujitsu Interstage Application Server powered by Windows Azure". Archived from the original on August 10, 2011.
- ^ "Tested Configurations, Java EE6 - Fujitsu Interstage". Oracle.com. 2010-09-07. Retrieved 2012-07-18.
- ^ "Fujitsu Releases Interstage Application Server V10.1". Fujitsu.
- ^ "NEC WebOTX Application Server V9.x Certification".
- ^ "Apache TomEE". Openejb.apache.org. Retrieved 2012-07-18.
- ^ "MarketWatch.com". MarketWatch.com. Retrieved 2012-07-18.
- ^ TomEE, Apache. "Apache TomEE 7.0.1".
- ^ "Resin Application Server Java EE 6 Web Profile" (PDF). caucho.com. 2011. Archived (PDF) from the original on 2022-10-09.
- ^ "Please Welcome Siwpas as Java EE Certified Option!". Oracle.com. Retrieved 2015-12-07.
- ^ "JOnAS 5.3.0 RC1 released". jonas.ow2.org. 2013-01-07. Archived from the original on 2013-10-15. Retrieved 2014-02-25.
- ^ "SAP NetWeaver Cloud Java EE 6 Web Profile Certified! (The Aquarium)".
- ^ "SAP Software Solutions - Business Applications and Technology". Archived from the original on 2009-12-07. Retrieved 2010-05-03.
External links
[edit]- Official website
- The Official Jakarta EE Tutorial
- First Cup of Jakarta EE Tutorial: An Introduction to Jakarta EE
- Jakarta EE Specification Guide - Jakarta EE Platform
- Jakarta EE Official Starter: Generate a Jakarta EE Project
- Java Platform, Enterprise Edition (Java EE), Oracle Technology Network
- Jakarta EE official YouTube channel
Jakarta EE
View on Grokipediajavax.* to jakarta.* packages.[2]
Overview
Definition and Scope
Jakarta EE is an open-source specification suite that evolved from Java EE, serving as the evolution of enterprise Java technologies under the governance of the Eclipse Foundation since 2017. It focuses on enabling cloud-native, lightweight, and traditional enterprise Java applications by providing standardized APIs for building scalable, secure, and reliable server-side software. Managed through the vendor-neutral Jakarta EE Working Group, it emphasizes rapid innovation and compatibility with modern deployment environments like microservices, Docker, and Kubernetes.[9] The scope of Jakarta EE centers on extending the Java SE platform with server-side APIs for key enterprise functionalities, including web technologies, business logic processing, data persistence, and system integration, without constituting a complete software distribution. It includes specifications for services such as messaging, transactions, security, and persistent data management, organized into modular profiles: Core Profile for foundational elements, Web Profile adding web application support, and Full Platform incorporating advanced features like batch processing and messaging. This modularity allows developers to select subsets of APIs tailored to application needs, promoting portability across compatible runtimes.[10][9][2] A key aspect of Jakarta EE is its adoption of thejakarta.* namespace starting with version 9, replacing the previous javax.* packages to distinguish it from Oracle-controlled Java EE while maintaining backward compatibility where possible. It requires Java SE 11 or later as a baseline, with recent releases such as Jakarta EE 11 updating the minimum to Java SE 17 or higher to leverage features like virtual threads and records. This ensures applications can run portably and scalably on certified runtimes that pass the Technology Compatibility Kit (TCK), guaranteeing adherence to the specifications across diverse vendors.[9][2]
Key Features and Benefits
Jakarta EE emphasizes modularity through its profiles, enabling developers to select lightweight subsets tailored for specific needs, such as the Core Profile for microservices or the full platform for comprehensive enterprise applications. This approach allows for flexible, scalable deployments without requiring the entire stack, promoting efficiency in resource-constrained environments like cloud-native setups.[11] A core strength lies in its built-in support for Contexts and Dependency Injection (CDI), which automates dependency management and lifecycle handling, fostering loosely coupled components that simplify testing and maintenance. Annotations enable declarative programming, reducing the need for verbose XML configurations, while the JSON Processing API facilitates efficient handling of modern data formats in web and enterprise applications. Compared to legacy Java EE, these features significantly cut boilerplate code, streamlining development workflows and enhancing productivity.[12] Portability across multiple vendor implementations ensures consistent behavior and long-term stability, allowing applications to migrate seamlessly between compatible runtimes without vendor lock-in. Alignment with contemporary Java features, such as records in Jakarta EE 11, further integrates immutable data structures to minimize code verbosity and improve type safety. Security is bolstered by native integration with OAuth 2.0 via OpenID Connect support in Jakarta Security, enabling secure authentication for distributed systems, alongside the removal of the deprecated SecurityManager in EE 11 to simplify runtime configurations while preserving robust protection mechanisms.[11][2] For cloud-native performance, Jakarta EE optimizes deployments with reactive messaging capabilities that support non-blocking, event-driven architectures for high-throughput scenarios, and RESTful services through the JAX-RS API for building scalable APIs. These elements collectively enable enterprises to achieve better resource utilization, faster response times, and easier scaling in containerized environments, making it ideal for microservices and hybrid cloud strategies.History
Origins in Java EE
The Java 2 Platform, Enterprise Edition (J2EE) was initially released by Sun Microsystems on December 17, 1999, as version 1.2, establishing a standardized framework for developing multi-tier enterprise applications using Java technologies.[13] This release introduced core components such as Enterprise JavaBeans (EJB) for business logic, Java Servlets for web handling, and JavaServer Pages (JSP) for dynamic content generation, aiming to address the complexities of distributed computing while promoting portability across vendor implementations.[14] Over the subsequent years, the platform evolved through iterative updates, with J2EE 1.3 in 2001 and 1.4 in 2003 enhancing messaging, web services, and integration capabilities, but these versions retained verbose configuration requirements that increased development overhead.[15] A significant advancement occurred with the rebranding to Java EE 5 in May 2006, which introduced annotations and a simplified programming model to reduce boilerplate code and XML descriptors, making enterprise development more accessible and aligned with plain old Java object (POJO) paradigms.[16] Key milestones in this release included the EJB 3.0 specification, which enabled POJO-based enterprise beans by minimizing invasive interfaces and callbacks, allowing developers to focus on business logic rather than container-specific details.[16] Similarly, JavaServer Faces (JSF) 1.2 provided a component-based framework for building web user interfaces, supporting event-driven interactions and reusable UI components to streamline front-end development.[17] The Java Persistence API (JPA) 1.0 emerged as the standard for object-relational mapping (ORM), offering a portable way to manage entity persistence without tying applications to proprietary persistence solutions.[18] Following Sun Microsystems' acquisition by Oracle Corporation, completed on January 27, 2010, Oracle assumed stewardship of Java EE, continuing its evolution under the Java Community Process (JCP).[19] Under Oracle's leadership, the platform advanced to Java EE 8, released on August 31, 2017, which incorporated modern features such as HTTP/2 support in Servlet 4.0 for improved web performance and the JSON Binding (JSON-B) API for efficient mapping between Java objects and JSON data structures.[20] However, this era also highlighted challenges, including perceptions of vendor lock-in due to Oracle's influence over implementations like GlassFish and the introduction of proprietary extensions that deviated from pure specifications, fostering concerns about long-term openness and interoperability.[21] These issues ultimately contributed to the platform's transition to open governance.Transition to Eclipse Foundation
In September 2017, Oracle, in collaboration with IBM and Red Hat, announced the donation of Java EE technologies—including specifications, reference implementations, and Technology Compatibility Kits (TCKs)—to the Eclipse Foundation to accelerate innovation amid enterprises' shift to cloud-native models and to foster broader open-source collaboration.[22] The transfer necessitated a rebranding, as Oracle retained control over the "Java" trademark and did not grant permission for its use under Eclipse governance; consequently, in February 2018, following a community poll with over 6,900 votes, the platform was renamed Jakarta EE. The inaugural release, Jakarta EE 8 in September 2019, mirrored Java EE 8 in functionality while retaining the javax.* package namespace to ensure backward compatibility for existing applications and libraries.[23][24] To guide the platform's community-driven evolution, the Eclipse Foundation established the Jakarta EE Working Group in early 2018, with initial strategic members including IBM, Red Hat, Oracle, Fujitsu, Payara Services, and Tomitribe, responsible for specification development, branding promotion, and ecosystem coordination through open processes.[25][26] Among the early hurdles in this handover were the complexities of relicensing over 30 projects to the Eclipse Public License 2.0 and adapting TCKs for compatibility certification under community oversight, which required building new infrastructure for testing and builds. The transition also foreshadowed namespace challenges, culminating in the mandatory shift from javax.* to jakarta.* packages in subsequent releases like Jakarta EE 9, which demanded widespread code refactoring in applications and dependencies to resolve import conflicts and maintain interoperability.[27][28]Major Releases and Evolution
Jakarta EE 8, released on September 10, 2019, marked the first version under the Eclipse Foundation's stewardship and maintained full binary compatibility with its predecessor, Java EE 8.[29] This release incorporated the same set of specifications as Java EE 8, including updates such as Contexts and Dependency Injection (CDI) 2.0 for improved dependency management and Bean Validation 2.0 for enhanced constraint validation, without introducing new features but establishing a collaborative governance model for future evolution.[30] The platform remained compatible with Java SE 8, ensuring a smooth transition for existing enterprise applications while laying the groundwork for namespace changes in subsequent versions.[3] Jakarta EE 9, finalized on December 8, 2020, focused primarily on the mandatory adoption of thejakarta.* namespace across all specifications, replacing the former javax.* packages to resolve trademark issues and enable independent evolution.[31] This release introduced no new APIs or features, emphasizing migration compatibility and requiring updates to build tools and codebases, while maintaining support for Java SE 8.[32] A minor update, Jakarta EE 9.1, arrived on May 25, 2021, adding certification compatibility with Java SE 11 to align with evolving JVM standards.[8] These changes were essential for decoupling from legacy dependencies and fostering broader community contributions.[33]
The release of Jakarta EE 10 on September 22, 2022, represented a significant advancement by introducing new specifications and enhancements tailored to modern development needs.[34] It also featured updates to REST-related technologies, such as JSON Processing (JSON-P) 2.1 for better streaming support and improved HTTP client capabilities, alongside a baseline requirement for Java SE 11.[35] Additionally, Jakarta EE 10 debuted the Core Profile, a lightweight subset of specifications designed for cloud-native and MicroProfile compatibility, promoting modular deployments.[36]
Jakarta EE 11, completed with its full platform release on June 26, 2025, followed a phased rollout beginning with the Core Profile in December 2024 and the Web Profile in March 2025, enabling incremental adoption.[37] This version updated 16 specifications and introduced support for Java records for concise data modeling, while removing reliance on the deprecated SecurityManager in line with Java SE 21 advancements.[2] Notable enhancements encompassed modernized testing frameworks for improved automation and OAuth 2.0 flows in Jakarta Security for secure authorization, alongside expanded compatibility with Java SE 21 to leverage virtual threads and other performance optimizations.[38] These updates emphasize developer productivity and lightweight runtimes suitable for containerized environments.[39]
The evolution of Jakarta EE continues to prioritize cloud-native capabilities, with the 2025 Eclipse Foundation Developer Survey indicating 58% adoption among enterprise Java developers and a rise in modular, cloud-oriented deployments from 31% in 2024.[40] This trend underscores growing integration with microservices and Kubernetes, positioning Jakarta EE as a key enabler for scalable, resilient applications in contemporary infrastructures.[41]
Specifications
Web Specifications
The web specifications in Jakarta EE provide the foundational APIs for developing dynamic web applications, focusing on handling HTTP interactions, generating content, and managing user interfaces within the web tier. These specifications are integral to the Jakarta EE Web Profile, which targets lightweight web application development. In Jakarta EE 11, released on June 26, 2025, the web specifications have been updated to align with Java SE 17 and 21, incorporating support for modern Java features such as records and virtual threads while enhancing performance and security.[39][2] Jakarta Servlet 6.1 serves as the core mechanism for processing HTTP requests and responses in web applications. It defines a server-side API that enables developers to create servlets—Java classes that extend the functionality of web servers—along with filters for intercepting requests and asynchronous processing to handle long-running operations without blocking threads. Key enhancements in version 6.1 include deprecation of HTTP/2 push support and improved alignment with Jakarta EE 11's baseline for cloud-native deployments.[42][43] Jakarta Pages 4.0, formerly known as Jakarta Server Pages (JSP), offers a templating technology for generating dynamic web content by combining static markup like HTML or XML with embedded Java code, expression language expressions, and custom tag libraries. This specification compiles pages into servlets at runtime or deployment, facilitating reusable components and separation of presentation logic from business logic. In Jakarta EE 11, version 4.0 introduces refinements for better integration with contemporary Java features, emphasizing simplicity in web view rendering. Jakarta Faces 4.1 provides a component-based framework for building user interfaces in model-view-controller (MVC) web applications, allowing developers to create reusable UI components, manage state across requests, and handle events such as form submissions. It supports integration with WebSocket for real-time bidirectional communication, enabling features like live updates in web applications. The update to 4.1 in Jakarta EE 11 enhances integration with Contexts and Dependency Injection (CDI), including making the current Flow injectable via CDI and requiring CDI lifecycle events for @ViewScoped and @FlowScoped scopes, while deprecating unused events related to legacy custom scopes removed in earlier versions, further streamlining development and improving testability.[44][45][46] Jakarta Expression Language 6.0 defines a lightweight scripting language for embedding dynamic expressions within web pages, JSP tags, or JSF components, supporting operations on objects, arrays, and maps without full Java code. It facilitates value binding and method invocation in a concise syntax, such as${expression} for immediate evaluation. Version 6.0 adds support for Java records and Optional types, enhancing expressiveness in modern web templating.[47]
These web specifications integrate seamlessly with Jakarta Contexts and Dependency Injection (CDI) 4.1, which enables declarative dependency injection into servlets, filters, and other web components, promoting loose coupling and easier maintenance in the web tier. CDI's interceptors and decorators further allow cross-cutting concerns like logging or security to be applied uniformly across web layers.[48][49]
Web Services Specifications
Jakarta EE's Web Services Specifications enable the development of interoperable, service-oriented APIs that facilitate communication between distributed applications, emphasizing standards for REST, SOAP, real-time interactions, and data serialization while integrating security for endpoint protection. These specifications build on HTTP and related protocols to support modern enterprise integration without delving into core web container handling. Jakarta RESTful Web Services (JAX-RS) 4.0 provides a standardized API for creating and consuming RESTful web services using annotations to map Java methods to HTTP resources. Developers can define resource classes with annotations such as@Path for URI mapping, @GET for retrieval operations, and @POST for resource creation, allowing automatic serialization and deserialization of request/response payloads. The specification supports hypermedia as the engine of application state (HATEOAS) through link representations and includes client-side APIs for invoking remote services. A key enhancement in version 4.0 is the introduction of reactive client support, enabling asynchronous, non-blocking interactions via integration with reactive programming models like those in Jakarta Concurrency. This allows for scalable handling of high-throughput scenarios in microservices architectures.[50][51]
Jakarta JSON Binding (JSON-B) 3.0 offers a binding layer for converting between Java objects and JSON documents, essential for REST API payloads in web services. It defines a default mapping algorithm that automatically handles type conversions, such as mapping Java beans to JSON objects and collections to arrays, using annotations like @JsonbProperty for customization. The API includes JsonbBuilder for creating binding instances and supports adapters for complex types, ensuring portability across implementations. Version 3.0 aligns with Java SE 11 requirements and introduces improvements in performance for large-scale data serialization, making it suitable for efficient API data exchange in service-oriented applications.[52][53]
Jakarta SOAP Web Services (JAX-WS) 4.0, part of the broader Jakarta XML Web Services, enables the creation of XML-based SOAP web services with support for Web Services Description Language (WSDL) contracts. It provides annotations like @WebService to expose Java interfaces as SOAP endpoints and tools for generating client stubs from WSDL documents, ensuring interoperability with legacy and enterprise systems. The specification includes handlers for message processing and attachments via Jakarta SOAP with Attachments (SAAJ), allowing secure, reliable messaging through WS-* standards. Aligned with Jakarta EE 11, version 4.0 requires Java SE 17 or higher and focuses on namespace updates to jakarta.xml.ws for consistency.[54][55]
Jakarta WebSocket 2.2 defines APIs for full-duplex, bidirectional communication over a single TCP connection, ideal for real-time web applications such as chat systems or live updates in service endpoints. Server endpoints are implemented using annotated classes extending Endpoint or implementing MessageHandler, with methods triggered by events like @OnMessage for incoming data. The client API supports connecting to remote WebSocket servers and handling sessions, compliant with RFC 6455. Version 2.2 updates the namespace to jakarta.websocket and includes extensions for programmatic endpoint configuration, enhancing scalability for push-based services in distributed environments.[56][57]
Security for web service endpoints in Jakarta EE is provided through Jakarta Authentication 3.1, which offers a pluggable SPI for authentication mechanisms integrated with service containers. It allows developers to define custom authenticators using AuthConfigFactory and ServerAuthModule to protect REST or SOAP endpoints, supporting mechanisms like HTTP Basic, OAuth, or custom tokens. This specification ensures portable security configurations across compliant runtimes, with propagation of caller identities to downstream services.[58][59]
Enterprise Specifications
Jakarta Enterprise Specifications form the core of Jakarta EE for handling business logic, data persistence, and transactional integrity in scalable applications. These specifications enable developers to build modular, maintainable components that integrate seamlessly within the Jakarta EE platform, supporting features like dependency management and validation without relying on proprietary implementations. They emphasize standardization to promote portability across certified runtimes, with updates in recent versions focusing on namespace migration tojakarta.* and compatibility with modern Java SE versions.[7]
Jakarta Enterprise Beans (EJB) 4.0.1 defines an architecture for developing component-based business applications, providing simplified mechanisms for session beans and message-driven beans enhanced by interceptors. Session beans encapsulate business logic, allowing stateless, stateful, or singleton instances to handle client requests efficiently, while message-driven beans process asynchronous messages from messaging systems like JMS, with interceptors enabling cross-cutting concerns such as security and logging to be applied modularly. The specification requires Java SE 17 or higher and introduces the jakarta.* namespace as a breaking change from prior versions, removing outdated features like JAX-RPC support and EJB 2.x entity beans to streamline development. This version, aligned with Jakarta EE 11, marks optional the EJB 2.x API group to reduce container overhead while maintaining backward compatibility for core functionalities.[60]
Jakarta Contexts and Dependency Injection (CDI) 4.1 offers a standardized approach to managed beans and portable extensions, promoting loose coupling by injecting dependencies declaratively rather than through manual instantiation or service locators. It maximizes reusability, testability, and maintainability by defining contexts for bean lifecycles, events for communication, and interceptors for aspect-oriented programming, allowing extensions to customize the container's behavior without vendor lock-in. Key enhancements in this version include a split into CDI Lite for resource-constrained environments and full CDI, defaulting bean discovery to "annotated" mode for empty beans.xml files, and support for build-time compilation via the jakarta.enterprise.lang-model API, requiring Java SE 17 or higher. As part of Jakarta EE 11, CDI 4.1 integrates with the Java Platform Module System through module-info.class files in its API artifacts.[48]
Jakarta Persistence (JPA) 3.2 establishes an object-relational mapping (ORM) standard for entity management, query execution via JPQL, and caching strategies to bridge Java objects with relational databases. It provides the EntityManager API for CRUD operations, lifecycle callbacks, and query optimization, with JPQL supporting SQL-like queries including new functions like CEILING, EXP, LOCAL DATE, and EXTRACT for temporal and mathematical operations, alongside Criteria API extensions for type-safe query construction. Caching is handled through first- and second-level caches to improve performance, with entities mappable to tables via annotations like @Entity and @Id. This version, aligned with Jakarta EE 11, mandates Java SE 17 or higher, adds UUID support in GenerationType.UUID, and makes EntityManager and EntityManagerFactory implement AutoCloseable for better resource management.[61]
Jakarta Transactions (JTA) 2.0.1 standardizes distributed transaction management, enabling the demarcation of transaction boundaries and coordination among XA-compliant resource managers for atomicity across multiple data sources. It defines Java interfaces like UserTransaction for programmatic control and TransactionManager for container-managed transactions, supporting the two-phase commit protocol inherent in XA resources to ensure consistency in enterprise scenarios involving databases and message queues. The specification facilitates integration with other Jakarta EE components, such as EJBs and JPA, by propagating transaction contexts transparently. Aligned with Jakarta EE 11, it requires Java SE 17 or higher and adopts the jakarta.* namespace without introducing deprecations or incompatibilities.[62]
Jakarta Validation (Bean Validation) 3.1 provides a declarative model for applying constraints to JavaBeans and methods, ensuring data integrity through annotations like @NotNull, @Size, and @Email on fields, properties, or parameters. It includes a validation API for programmatic checks via Validator instances, supporting constraint validators for custom logic and integration with other specifications like JPA for entity validation or CDI for injection points. The metadata model allows constraints to propagate in inheritance hierarchies and container elements, with built-in constraints covering common validation needs. Aligned with Jakarta EE 11, this version supports Java SE 17 or higher and shifts to the jakarta.* namespace, maintaining full backward compatibility without removals.[63]
Additional Specifications
Jakarta Batch 2.1 provides a standardized programming model for developing and executing batch applications, enabling the processing of large volumes of data through jobs composed of steps, chunks, and reusable artifacts. It includes a Java API for implementing batch logic, such as item readers, processors, and writers, along with an XML-based Job Specification Language (JSL) for defining job structures, parameters, and flows. This specification supports job scheduling via integration with Jakarta EE containers, allowing for restartability, checkpointing, and partitioning to handle scalable data operations efficiently.[64] Jakarta Messaging 3.1, formerly known as the Java Message Service (JMS) API, standardizes asynchronous communication in enterprise applications by facilitating message exchange between producers and consumers through queues for point-to-point messaging and topics for publish-subscribe patterns. It defines interfaces for connections, sessions, destinations, and message delivery, ensuring reliable, transactional, and ordered message handling across loosely coupled components. Enhancements in this version include repeatable annotations for configuration and support for Jakarta EE 11's namespace changes, promoting integration with other specifications like Jakarta Enterprise Beans for enterprise messaging scenarios.[65] Jakarta Security 4.0 establishes a flexible framework for securing Jakarta EE applications, emphasizing programmatic and declarative approaches to authentication and authorization in modern, container-agnostic environments. It introduces identity stores for credential validation, authorization policies for access control based on roles and permissions, and propagation policies to maintain security context across distributed calls. This version aligns with Jakarta EE 11 by adding support for OpenID Connect integration and deprecating legacy features like the SecurityManager, enabling secure development for cloud-native and microservices architectures.[66] Jakarta Data 1.0, introduced as a new specification in Jakarta EE 11, offers a repository-based abstraction for unified data access across relational and NoSQL databases, allowing developers to define type-safe repository interfaces without boilerplate code. It supports multi-repository patterns with features like method-name queries, pagination, and integration with Jakarta Persistence, NoSQL, and Transactions for consistent data operations. By separating persistence logic from domain models, it simplifies hybrid data environments while maintaining compatibility with Java SE 17 and higher.[67] Jakarta MVC 3.0 delivers a lightweight, action-oriented Model-View-Controller framework built atop Jakarta RESTful Web Services, serving as an alternative to component-based approaches like Jakarta Server Faces for developing RESTful web applications. It routes HTTP requests to controller methods that manipulate models and select views, with built-in support for binding, validation, and templating engines such as Thymeleaf or Freemarker. This specification, aligned with Jakarta EE 11, focuses on simplicity for rapid prototyping and micro-web apps through namespace updates and CDI integration.[68]Profiles
Web Profile
The Jakarta EE Web Profile is a lightweight subset of the Jakarta EE Platform designed specifically for developing web-centric applications, providing a focused set of specifications that enable efficient, portable web development without the overhead of full enterprise features.[69] It emphasizes modularity and simplicity, allowing developers to build applications that deploy as web archive (WAR) files while supporting essential web technologies.[70] The Web Profile's composition includes key specifications such as Jakarta Servlets for handling HTTP requests, Jakarta Server Pages (JSP) for dynamic content generation, Jakarta Server Faces (JSF) for user interface components, Jakarta RESTful Web Services (JAX-RS) for building RESTful APIs, Jakarta JSON Processing (JSON-P) and JSON Binding (JSON-B) for JSON handling, Contexts and Dependency Injection (CDI) for managing dependencies, Bean Validation for data validation, Jakarta Persistence (JPA) for data access, Jakarta Data for repository abstractions, and Interceptors for cross-cutting concerns.[69] These components form a cohesive stack tailored for web layers, excluding heavier enterprise elements like full Enterprise JavaBeans (EJB) or advanced transaction management beyond basic needs.[70] Targeted at modern web applications and microservices, the Web Profile supports scenarios where applications need to respond quickly to requests without requiring comprehensive backend services, making it suitable for distributed architectures. It omits resource-intensive features to focus on web-oriented development, enabling seamless integration into lightweight environments.[69] Key benefits include a smaller runtime footprint and faster startup times compared to the full platform, which reduces resource consumption and improves scalability in containerized deployments such as those on Kubernetes.[70] Certified in Jakarta EE 11, it provides full support for Java SE 21, leveraging modern language features like records and virtual threads for enhanced performance.[70] This makes it ideal for cloud-native applications where rapid iteration and low latency are critical.[39] Certification for Web Profile compatibility requires implementations to pass the Technology Compatibility Kit (TCK) tests for all included specifications, ensuring portability across vendors and adherence to the standard.[69] Successful certification allows vendors to use the official Jakarta EE Compatible logo, promoting interoperability in web application ecosystems.Full Platform
The Jakarta EE Full Platform represents the comprehensive edition of the specification suite, designed to support the development and deployment of robust, large-scale enterprise applications. It encompasses the entire set of APIs and technologies required for building complex systems that demand advanced capabilities beyond basic web applications. Unlike lighter profiles, the Full Platform integrates all components necessary for handling distributed transactions, asynchronous messaging, batch processing, and secure enterprise integration, making it suitable for environments where scalability and reliability are paramount.[2] In terms of composition, the Full Platform includes all specifications from the Web Profile—such as Jakarta Servlet, Jakarta Server Pages, Jakarta RESTful Web Services, and Jakarta Contexts and Dependency Injection—augmented by additional enterprise-focused technologies. Key additions include Jakarta Enterprise Beans (EJB) for managing business logic in distributed environments, Jakarta Transactions (JTA) for coordinating atomic operations across resources, Jakarta Messaging (JMS) for reliable asynchronous communication, Jakarta XML Web Services (JAX-WS) for SOAP-based interoperability, Jakarta Batch for processing large-scale data jobs, and enhanced security features via Jakarta Security and Jakarta Authentication. This full assembly ensures a complete runtime environment for monolithic or microservices-based architectures that require end-to-end enterprise functionality. The platform's specifications are detailed in the official Jakarta EE 11 documentation, which lists over 30 integrated components, including Jakarta Persistence for object-relational mapping and Jakarta Connectors for resource adapters.[71][2] Targeted at monolithic or distributed enterprise applications, the Full Platform addresses use cases involving high-volume transactions, such as financial systems, e-commerce backends, and supply chain management, where components like JMS enable decoupled messaging patterns and JTA ensures data integrity across multiple databases. It supports the orchestration of complex workflows, including batch-oriented tasks for ETL (extract, transform, load) processes via Jakarta Batch, and secure access controls for sensitive operations. Developers leverage this platform when applications must scale horizontally while maintaining ACID (atomicity, consistency, isolation, durability) compliance, contrasting with the Web Profile's focus on simpler web-tier deployments.[38][2] The evolution of the Full Platform in Jakarta EE 11 emphasizes alignment with contemporary Java features, introducing support for Java records for immutable data structures, virtual threads from Java 21 for efficient concurrency without traditional thread overhead, and the new Jakarta Data 1.0 specification for streamlined repository abstractions. These updates require a minimum Java SE 17 runtime, increasing footprint compared to prior versions but enabling better performance in cloud-native and reactive scenarios. While the core enterprise specs like EJB and JTA receive minor enhancements for compatibility, the platform removes deprecated elements such as ManagedBeans to streamline development.[2][71][72] Certification for Full Platform implementations mandates rigorous compliance with Technology Compatibility Kits (TCKs) for every included specification, ensuring portability and interoperability across vendors. Compatible products, such as those earning the Jakarta EE Compatible logo, must pass these TCKs on Java SE 17 or 21, with tests modernized using tools like Maven and Arquillian for automated validation. Backward compatibility is maintained for most APIs to facilitate migrations from earlier versions, though removals like the SecurityManager requirement may necessitate code adjustments in legacy applications. This process upholds the platform's stability for enterprise adoption, as outlined in the Eclipse Foundation's compatibility guidelines.[2][38]Implementations
Certified Runtimes
Certified runtimes for Jakarta EE are application servers and platforms that have undergone the official certification process to ensure full compatibility with the platform's specifications. This process requires vendors to execute the Technology Compatibility Kit (TCK), a comprehensive suite of tests verifying adherence to Jakarta EE APIs and behaviors, and to publish detailed results publicly.[73] Upon approval by the Eclipse Foundation's Jakarta EE Working Group, certified products are listed on the official compatibility page at jakarta.ee, covering versions from Jakarta EE 8 through 11, with separate categories for Full Platform, Web Profile, and Core Profile support where applicable.[74] Eclipse GlassFish serves as the reference implementation for Jakarta EE, providing an open-source, modular runtime that developers can use to validate applications against the platform standards. Certified for both the Full Platform and Web Profile in Jakarta EE 11 (versions 8.0.0-M12 and 8.0.0-M10, respectively, supporting Java 17 and 21), it features lightweight distributions allowing selective inclusion of components for optimized deployments.[74][75] Its role as the TCK ratifying implementation ensures it embodies the exact behaviors defined in the specifications.[75] WildFly, the community-driven evolution of the former JBoss application server, offers a full-stack, modular runtime emphasizing high performance and scalability for enterprise applications. It is compatible with Jakarta EE 11, with certification for the Core Profile (version 34.0.0.Final, supporting Java 17 and 21), including advanced features like clustering for distributed environments and integrated management tools such as a web console, CLI, and REST API.[74][76] These capabilities make it suitable for large-scale deployments requiring fault tolerance and centralized configuration.[76] Payara Server, an enterprise-grade fork of GlassFish, integrates seamlessly with Jakarta EE while adding DevOps-oriented enhancements for modern infrastructures. Certified for both the Full Platform and Web Profile in Jakarta EE 11 (version 7.2025.1 as of November 2025), it supports Eclipse MicroProfile for microservices and provides native Kubernetes integration through tools like Payara Qube, enabling automated scaling and zero-downtime deployments in cloud-native settings.[74][77][78] This focus on containerization and observability positions it as a bridge between traditional enterprise Java and cloud operations.[77] Open Liberty delivers a lightweight, fast-starting runtime optimized for cloud and microservices architectures, using a feature-pack model where only necessary components are enabled to minimize footprint. Certified for the Jakarta EE 11 Web Profile and Core Profile (version 24.0.0.11-beta, supporting Java 17 and 21), it excels in containerized environments with zero-migration support across clouds and rapid provisioning for development workflows.[74][79] Its modular design facilitates seamless upgrades and integration with Kubernetes, making it ideal for agile teams building scalable web applications.[79] Other certified runtimes include Fujitsu Software Enterprise Application Platform 2.0.0 for the Core Profile.[74]Development and Deployment Tools
Development and deployment of Jakarta EE applications are facilitated by a range of integrated tools that support integrated development environments (IDEs), build automation, testing frameworks, containerization, orchestration, and migration utilities. These tools streamline workflows from code authoring to production deployment, ensuring compatibility with the Jakarta EE platform's specifications and certified runtimes such as GlassFish.[2] Integrated development environments provide robust support for Jakarta EE through dedicated plugins and packages. The Eclipse IDE for Enterprise Java Developers includes built-in support for Jakarta EE, featuring tools for editing annotations, generating code, and integrating with Technology Compatibility Kits (TCKs) via the Eclipse Jakarta Tools project.[80] IntelliJ IDEA offers the Jakarta EE Platform plugin, which enables project templates, artifact management, and TCK validation, along with specialized plugins for components like Jakarta Server Faces (JSF) and Enterprise JavaBeans (EJB).[81][82] Build tools simplify dependency management and project scaffolding for Jakarta EE applications. Maven utilizes the official Jakarta EE Bill of Materials (BOM) to align versions of jakarta.* dependencies across specifications, while archetypes generate starter projects with pre-configured structures for web applications and enterprise archives.[83][84] Gradle supports Jakarta EE through plugins like the Jakarta EE Migration Plugin for namespace updates and dependency substitutions, enabling BOM-like management via platform declarations in build scripts.[85] Testing frameworks enhance verification of Jakarta EE components at various levels. Arquillian provides container-agnostic integration testing by embedding tests within real runtimes, supporting Jakarta EE 10 and later for functional validation of EJBs, REST endpoints, and CDI beans.[86][87] REST Assured facilitates API testing with a domain-specific language for HTTP assertions, compatible with Jakarta EE via upgrades that migrate from javax to jakarta namespaces.[88][89] Deployment tools focus on containerization and orchestration for scalable Jakarta EE applications. Official Docker images are available for certified runtimes like Payara Server and WildFly, allowing multi-stage builds that package applications efficiently for cloud-native environments.[90] Helm charts enable Kubernetes deployment of Jakarta EE servers, such as those for Open Liberty, by defining configurable manifests for pods, services, and scaling.[91] Jenkins supports CI/CD pipelines tailored for Jakarta EE, automating builds, tests, and deployments to runtimes via plugins for Maven, Docker, and Kubernetes integration.[92] Migration tools assist in transitioning legacy Java EE codebases to Jakarta EE. OpenRewrite offers recipes that automate the update of javax.* imports to jakarta.*, handle deprecated methods, and adjust dependencies for versions 9 through 11.[93]Practical Usage
Application Architecture
Jakarta EE applications typically follow a multitier or layered architecture to promote separation of concerns, scalability, and maintainability. This structure divides the application into distinct layers: presentation, business, persistence, and integration. The presentation layer handles user interactions using technologies such as Jakarta Servlets for HTTP request processing and Jakarta Server Faces (JSF) for building component-based user interfaces.[10] The business layer encapsulates core logic through Contexts and Dependency Injection (CDI) for managing beans and loose coupling, or Enterprise JavaBeans (EJB) for transactional and secure operations.[10] The persistence layer manages data access via Jakarta Persistence (JPA) for object-relational mapping, often complemented by Java Database Connectivity (JDBC).[10] The integration layer facilitates communication with external systems using Jakarta Messaging (JMS) for asynchronous messaging or Jakarta RESTful Web Services (JAX-RS) for API-based interactions.[10] In a microservices approach, Jakarta EE leverages the Web Profile to develop lightweight, independent services that can be deployed separately, with CDI serving as the primary mechanism for dependency wiring and inversion of control.[94] This enables modular decomposition of larger applications into focused services, often integrated with MicroProfile specifications for cloud-native features like configuration and health checks.[10] Best practices emphasize annotation-driven configuration to simplify development and reduce boilerplate, allowing declarative specification of dependencies, transactions, and lifecycles directly in code.[10] Security is integrated via Jakarta Security, which provides portable mechanisms for authentication and authorization using annotations like @RolesAllowed.[95] Monitoring and observability can be enhanced through MicroProfile extensions, such as Metrics and Health, to track application performance in distributed environments.[96] Deployment patterns in Jakarta EE support evolution from monolithic structures to microservices by extracting bounded contexts into separate deployables, often using the Strangler Fig pattern to incrementally replace legacy components.[97] Containerization with tools like Docker and orchestration via Kubernetes enables horizontal scalability and portability across cloud environments.[98] A common pitfall is over-reliance on XML-based deployment descriptors, which can lead to verbosity and maintenance challenges; instead, annotations should be prioritized for modern, declarative configurations.[10]Code Examples
Jakarta EE provides a rich set of APIs for building enterprise applications, and code examples illustrate how these APIs integrate to handle common tasks such as web request processing, dependency injection, data persistence, transaction management, and data serialization. The following annotated examples draw from the official Jakarta EE Tutorial and specifications, demonstrating core concepts in a modular fashion. These snippets assume a compatible runtime like a certified Jakarta EE 11 server and focus on key annotations and methods without full application setup.[2]Simple Servlet Example Using Jakarta Servlet 6.1 Annotations
Jakarta Servlet 6.1, part of Jakarta EE 11, simplifies web application development by allowing declarative configuration via annotations, eliminating the need for deployment descriptors in many cases.[42] The@WebServlet annotation maps a servlet class to a URL pattern, handling HTTP requests such as GET. This example shows a basic servlet that responds to GET requests at the "/hello" path, generating a simple HTML response. The doGet method processes the request, sets the content type, and writes output using the response writer.
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
@WebServlet(name = "HelloServlet", urlPatterns = {"/hello"})
public class HelloServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
response.setBufferSize(8192); // Optional: Set buffer for efficiency
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>Hello World</title></head>");
out.println("<body><h1>Hello from Jakarta Servlet!</h1></body>");
out.println("</html>");
out.close();
}
}
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
@WebServlet(name = "HelloServlet", urlPatterns = {"/hello"})
public class HelloServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
response.setBufferSize(8192); // Optional: Set buffer for efficiency
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>Hello World</title></head>");
out.println("<body><h1>Hello from Jakarta Servlet!</h1></body>");
out.println("</html>");
out.close();
}
}
doPost can be added similarly.[99]
CDI Bean Injection in a REST Endpoint with JAX-RS 4.0
Contexts and Dependency Injection (CDI) in Jakarta EE enables loose coupling by injecting dependencies into managed beans, including JAX-RS resources. JAX-RS 4.0 defines RESTful web services, where@Path annotations map endpoints, and @Inject from CDI (Jakarta CDI 4.1) resolves service beans at runtime.[50][48] This example demonstrates a REST endpoint injecting a CDI-managed service to fetch data, returning a JSON response. The container scans for @RequestScoped or @ApplicationScoped beans to satisfy the injection.
Assume a simple CDI service bean:
import jakarta.enterprise.context.ApplicationScoped;
@ApplicationScoped
public class DataService {
public String getData() {
return "Data from CDI service";
}
}
import jakarta.enterprise.context.ApplicationScoped;
@ApplicationScoped
public class DataService {
public String getData() {
return "Data from CDI service";
}
}
import jakarta.enterprise.context.RequestScoped;
import jakarta.inject.Inject;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
@Path("/api/data")
@RequestScoped
public class DataResource {
@Inject
private DataService dataService;
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getData() {
String data = dataService.getData();
return Response.ok(data).build();
}
}
import jakarta.enterprise.context.RequestScoped;
import jakarta.inject.Inject;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
@Path("/api/data")
@RequestScoped
public class DataResource {
@Inject
private DataService dataService;
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getData() {
String data = dataService.getData();
return Response.ok(data).build();
}
}
DataService instance, which is managed by the container's bean manager. This promotes testability, as the service can be mocked or replaced without altering the resource class. JAX-RS 4.0 enhancements include better support for reactive streams, but this example focuses on synchronous injection.[100]
JPA Entity with Relationships and a Basic Repository Query Using JPQL
Jakarta Persistence (JPA) 3.2 models relational data as entities with annotations for mappings, including relationships like one-to-many.[61] Entities use@Entity and relationship annotations such as @OneToMany to define associations, enabling object-oriented data access. JPQL (Jakarta Persistence Query Language) provides a SQL-like syntax for querying entities, abstracting database specifics. This example shows a CustomerOrder entity with a bidirectional one-to-many relationship to LineItem, followed by a JPQL query to retrieve orders.
First, the LineItem entity:
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.GeneratedValue;
@Entity
public class LineItem {
@Id
@GeneratedValue
private Long id;
private String itemName;
private int quantity;
@ManyToOne
private CustomerOrder customerOrder; // Owning side of relationship
// Constructors, getters, setters
public LineItem() {}
// ... (omitted for brevity)
}
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.GeneratedValue;
@Entity
public class LineItem {
@Id
@GeneratedValue
private Long id;
private String itemName;
private int quantity;
@ManyToOne
private CustomerOrder customerOrder; // Owning side of relationship
// Constructors, getters, setters
public LineItem() {}
// ... (omitted for brevity)
}
CustomerOrder entity with relationship:
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.OneToMany;
import jakarta.persistence.CascadeType;
import java.util.List;
@Entity
public class CustomerOrder {
@Id
@GeneratedValue
private Long id;
private Long orderId;
private String customerName;
@OneToMany(mappedBy = "customerOrder", cascade = CascadeType.ALL)
private List<LineItem> lineItems; // Inverse side
// Constructors, getters, setters
public CustomerOrder() {}
// ... (omitted for brevity)
}
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.OneToMany;
import jakarta.persistence.CascadeType;
import java.util.List;
@Entity
public class CustomerOrder {
@Id
@GeneratedValue
private Long id;
private Long orderId;
private String customerName;
@OneToMany(mappedBy = "customerOrder", cascade = CascadeType.ALL)
private List<LineItem> lineItems; // Inverse side
// Constructors, getters, setters
public CustomerOrder() {}
// ... (omitted for brevity)
}
import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
import jakarta.persistence.Query;
import java.util.List;
public class OrderRepository {
@PersistenceContext
private EntityManager em;
public List<CustomerOrder> findAllOrders() {
Query query = em.createQuery("SELECT co FROM CustomerOrder co ORDER BY co.orderId");
return query.getResultList();
}
}
import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
import jakarta.persistence.Query;
import java.util.List;
public class OrderRepository {
@PersistenceContext
private EntityManager em;
public List<CustomerOrder> findAllOrders() {
Query query = em.createQuery("SELECT co FROM CustomerOrder co ORDER BY co.orderId");
return query.getResultList();
}
}
@OneToMany annotation ensures cascading operations (e.g., persisting an order saves its line items), while the JPQL query fetches all orders sorted by ID, leveraging entity relationships for joins. This is executed within a transaction via an EntityManager injected by the container, supporting databases like PostgreSQL or MySQL through JPA providers such as Hibernate.[101]
Transactional EJB Method Example with @TransactionAttribute
Enterprise JavaBeans (EJB) 4.0 provide declarative transaction management via the@TransactionAttribute annotation, specifying how methods interact with transactions (e.g., REQUIRED joins or starts a transaction). This is crucial for ensuring data consistency in business logic. The example below shows a stateful session bean with method-level attributes overriding the class default, demonstrating suspension and resumption of transactions.[102]
import jakarta.ejb.Stateful;
import jakarta.ejb.TransactionAttribute;
import jakarta.ejb.TransactionAttributeType;
import jakarta.ejb.TransactionManagement;
import jakarta.ejb.TransactionManagementType;
@Stateful
@TransactionManagement(TransactionManagementType.CONTAINER)
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) // Default: No transaction for bean methods
public class TransactionBean {
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) // Suspends any existing tx, starts new
public void firstMethod() {
// Business logic that requires isolation in a new transaction
System.out.println("Executing in new transaction");
}
@TransactionAttribute(TransactionAttributeType.REQUIRED) // Joins existing or starts new
public void secondMethod() {
// Business logic that must run transactionally
System.out.println("Executing in required transaction");
}
// thirdMethod and fourthMethod inherit NOT_SUPPORTED, run without tx
public void thirdMethod() {
// Non-transactional operation
}
}
import jakarta.ejb.Stateful;
import jakarta.ejb.TransactionAttribute;
import jakarta.ejb.TransactionAttributeType;
import jakarta.ejb.TransactionManagement;
import jakarta.ejb.TransactionManagementType;
@Stateful
@TransactionManagement(TransactionManagementType.CONTAINER)
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) // Default: No transaction for bean methods
public class TransactionBean {
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) // Suspends any existing tx, starts new
public void firstMethod() {
// Business logic that requires isolation in a new transaction
System.out.println("Executing in new transaction");
}
@TransactionAttribute(TransactionAttributeType.REQUIRED) // Joins existing or starts new
public void secondMethod() {
// Business logic that must run transactionally
System.out.println("Executing in required transaction");
}
// thirdMethod and fourthMethod inherit NOT_SUPPORTED, run without tx
public void thirdMethod() {
// Non-transactional operation
}
}
firstMethod always uses a new transaction, ideal for logging or auditing independent of the caller. secondMethod participates in the caller's transaction if present, rolling back on failure. This setup is used in Jakarta EE applications for robust, distributed transaction support via Jakarta Transactions.[103]
JSON-B Serialization for API Responses
Jakarta JSON Binding (JSON-B) 3.0 offers a standard API for mapping Java objects to JSON, useful for REST API responses in JAX-RS. Annotations like@JsonbProperty customize serialization, while Jsonb instances handle conversion. This example defines a Person class and serializes it to JSON, renaming the field for API compatibility. JSON-B ensures UTF-8 encoding and RFC 7159 compliance.[52]
Class definition:
import jakarta.json.bind.annotation.JsonbProperty;
public class Person {
@JsonbProperty("person-name") // Customizes JSON field name
private String name;
// Constructors, getters, setters
public Person() {}
public Person(String name) { this.name = name; }
public String getName() { return name; }
public void setName(String name) { this.name = name; }
}
import jakarta.json.bind.annotation.JsonbProperty;
public class Person {
@JsonbProperty("person-name") // Customizes JSON field name
private String name;
// Constructors, getters, setters
public Person() {}
public Person(String name) { this.name = name; }
public String getName() { return name; }
public void setName(String name) { this.name = name; }
}
import jakarta.json.bind.Jsonb;
import jakarta.json.bind.JsonbBuilder;
import jakarta.json.bind.JsonbConfig;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.core.MediaType;
@Path("/api/person")
public class PersonResource {
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getPerson() {
Person person = new Person("Fred");
JsonbConfig config = new JsonbConfig().withFormatting(true); // Optional: Pretty-print JSON
Jsonb jsonb = JsonbBuilder.create(config);
String json = jsonb.toJson(person); // Serializes to {"person-name": "Fred"}
return Response.ok(json).build();
}
}
import jakarta.json.bind.Jsonb;
import jakarta.json.bind.JsonbBuilder;
import jakarta.json.bind.JsonbConfig;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.core.MediaType;
@Path("/api/person")
public class PersonResource {
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getPerson() {
Person person = new Person("Fred");
JsonbConfig config = new JsonbConfig().withFormatting(true); // Optional: Pretty-print JSON
Jsonb jsonb = JsonbBuilder.create(config);
String json = jsonb.toJson(person); // Serializes to {"person-name": "Fred"}
return Response.ok(json).build();
}
}
toJson method produces compact or formatted JSON based on the config, integrating seamlessly with JAX-RS for automatic response handling when returning objects directly. For deserialization, fromJson reverses the process. Implementations like Eclipse Yasson provide the runtime, supporting adapters for complex types like dates.[104]