News Ticker

Java EE 8: Only What’s New – First Look

Java EE 8: Only What's New

My new book Java EE 8: Only What’s New covers all the new features of Java EE 8 and explains each one with code examples. Let’s have a look at some of the highlights of this book. If you can’t wait and want it now click here for a special launch discount.

What’s the Book About?

The book dives into all the new features of Java EE 8 and it back with lots of code examples. There is a GitHub repository dedicated to this book which contains all the books code examples: Source code: Java-EE-8-Only-Whats-New.

Java EE 8 Only Whats New Preview

What’s the Book Philosophy?

It’s about giving the developer just the details s/he needs to get up to speed quickly with Java EE 8 and no more. This is why the book covers what’s new in Java EE 8. This book is perfect for you if you are an experienced Java EE developer with very little spare time. You won’t spend time reading about Java EE features that you already know, just the one you don’t.

What does the Book Contain?

The book covers all new Java EE 8 features in these APIs:

Java API for JSON Binding 1.1 (JSR 367)

The JSON Binding API (JSON-B) provides support for the serialization and deserialization between Java objects and JSON. It provides default mappings for the conversion of POJOs to/from JSON and allows two forms of customization: annotations based customization and a runtime configuration builder. It also boasts integrations with Java API for JSON Processing 1.1.

The following code snippet serializes then deserialization an instance of a Book class:

String bookJson = JsonbBuilder.create().toJson(book);
Book book = JsonbBuilder.create().fromJson(bookJson, Book.class);

In the JSON-B chapter, I cover all features of this new API with code examples for each. Why not preview the GitHub repository: Java-API-for-JSON-Binding-1-0-JSR367.

Java EE Security API 1.1 (JSR 375)

This specification has been designed that modernizes the way security features are implemented in a Java EE application with an emphasis on simplification and standardization and takes full advantage of CDI.

An essential detail in its design is that it provides an alternative way to configure an identity store and authentication mechanisms and without replacing the existing security mechanisms. The principle benefit this brings developers is the capability to enable security in a web application without the need to implement vendor specific or proprietary solutions.

Let’s have a quick look at how to enable basic authentication with the @BasicAuthenticationMechanismDefinition annotation. The code snippet below shows how to trigger the use of the HTTP basic authentication for the realm name user-realm.

@DeclareRoles({ "admin", "user", "demo" })
@ServletSecurity(@HttpConstraint(rolesAllowed = "user"))
public class UserServlet extends HttpServlet { ... }

In the security chapter, I discuss in details and show with code examples all the features of this long-awaited API.

Servlet 4.0 (JSR 369)

The servlets get a major revision with two new features: server push and a runtime discovery of URL mapping API. Let’s take a quick look at server push. This feature is designed to anticipate the resource requirements of the client by pushing those resources into the browser’s cache. 

In the code snippet below you can see that the server push feature is exposed via a PushBuilder instance obtained from the HttpServletResponse instance passed to the request handling method. The path to the resource to push is set via the path() method and push to the client when the push() method is invoked.

protected void doGet(HttpServletRequest request, HttpServletResponse response)
 throws ServletException, IOException {
   PushBuilder pushBuilder = request.newPushBuilder();

In the Servlet chapter, I discuss how the server push feature can be implemented as a cross-cutting concern, how JSF gets this feature for free and how the new runtime discovery of URL mappings API works.

Contexts and Dependency Injection for Java 2.0 (JSR 365)

The headline features for this release are the capability to use CDI in a Java SE applications, asynchronous observers and events and priority setting for observer ordering.

Let’s have a look at the new async observer and events with priority feature. The code below shows an event firing and two observers with different priorities.

The result is that the observer AuditEventReciever1 (priority 10) is called before the observer AuditEventReciever2 (priority 100).

private Event<AuditEvent> event;

public void send(AuditEvent auditEvent) {;

// AuditEventReciever1.class
public void receive(@Observes @Priority(10) AuditEvent auditEvent) {
    // react to event

// AuditEventReciever2.class 
public void receive(@Observes @Priority(100) AuditEvent auditEvent) {
    // react to event

In the CDI 2.0 chapter, I show how to use CDI in a Java SE application and discuss the new async events and observers feature in more detail.

Bean Validation 2.0 (JSR 380)

The bean validation 2.0 release has been enhanced with a range of new features many of which have been requested by the community. Among the enhancements are some very useful constraints.

They are: @Email@NotEmpty@NotBlank@Positive@PositiveOrZero@Negative@NegativeOrZero@PastOrPresent and @FutureOrPresent. The code snippet below shows that the API now supports Optional and Java SE 8 date and time API.

Optional<@Size(min = 10) String> title
private @PastOrPresent Year released;
private @FutureOrPresent LocalDate nextVersionRelease;
private @Past LocalDate publishedDate;

In the Bena validation chapter, I show working code examples of all new constraint validations and discuss the other changes to the API with plenty of code examples.

Java API for RESTful Web Services 2.1 (JSR 370)

Even those this is a minor update it contains some very powerful features. The two headline features have got to be the new reactive client API that turns you REST endpoints reactive and Server-Sent Events

Let’s peak at the reactive client API. The Invocation.Builder (which is used to construct the client instance) has a new method, rx(). Its return type is a CompletionStage with the parameterized type Response.

CompletionStage<Response> cs1 = ClientBuilder.newClient()

The CompletionStage interface was introduced in Java 8 and provides for some interesting possibilities. In the JAX-RS chapter, I demonstrate how to use the reactive client to connect asynchronously to remote endpoints and use the advanced features of the CompletionStage interface to produce a composed result of the data collected from the endpoints. I also demonstrate, with code, how to use the server-sent event feature.

JavaServer Faces 2.3 (JSR 372)

The JFS 2.3 release targets community requested features and better integration for CDI and websockets. The most interesting feature is how Server Push has been integrated into the render lifecycle of the JSF engine and that this feature comes for free to any developer that adopts this version.

In the JSF chapter, I discuss how server push has been introduced and I cover some of the many other notable additions and changes.

Java API for JSON Processing 1.1 (JSR 374)

The JSON Processing 1.1 API is now up to date with the latest IEFT standards and now includes JSON Pointer, JSON Patch, and JSON Merge Patch.

Let’s take a look at JSON Pointer. A JSON Pointer defines a string expression that identifies a specific value within a JSON document. For example, given the JSON document below, the 2nd element in the topics array would be referred to with the JSON pointer expression: /topics/1.

   "topics": [

The code snippet below creates a JsonPointer and references the 2nd element in the topic array.


In the JSON-P chapter, I demonstrate all the new JSON features with plenty of code examples.

Java Persistence API 2.2 (JSR 338)

The JPA update is pretty small but includes some important changes. They are:

  • Ability to stream the result of a query execution
  • Annotations are now marked @Repeatable
  • Support has been added for basic Java 8 Date and Time types
  • AttributeConverter types are now CDI beans
  • An update to the persistence provider discovery mechanism

In the JPA chapter, I discuss these changes in a little more detail.

Bonus Chapter

I included a chapter about the HTTP/2 because it is related to the servlet API’s server push feature and gives the interested reader a bit more information about whats going on under the hood. The chapter covers: the topology of a connection, request/response multiplexingheader compressionstream prioritizationserver push, and flow control and a little bit more.

Where Can I get the Book?

Java EE 8: Only Whats New

The book is available now from:

You can get a special launch price from (only $9.95).

I hope you enjoy.

Leave a Reply

%d bloggers like this: