back to all blogsSee all blog posts

InstantOn with checkpoint/restore in Open Liberty 22.0.0.11-beta!

image of author
Reece Nana on Sep 29, 2022
Post available in languages:

Open Liberty 22.0.0.11-beta provides an exciting new capability called InstantOn, which provides incredibly fast startup times and can help reduce the overall cloud costs for cloud-native applications.

Since the 22.0.0.9-beta release, which included the Jakarta EE 10 Core Profile, Open Liberty has continued to beta more and more Jakarta EE 10 features. This beta release introduces various developer experience and performance enhancements available through the following new Jakarta EE 10 features: Servlet 6.0, Mail 2.1, Connectors 2.1 and Persistance 3.1.

The Open Liberty 22.0.0.11-beta includes the following new beta features (along with all GA features):

InstantOn with checkpoint/restore

Traditionally, starting an application can take several seconds, and sometimes minutes, before the application can service its first request. Longer startup times inhibit an application’s ability to scale to zero when deployed in a cloud environment such as Kubernetes, which in turn can drive up costs.

Liberty’s InstantOn capability is an innovative way to drastically reduce that startup time by using checkpoint/restore. Restoring an application from a checkpoint process can be up to 10 times faster than starting the Liberty application from the beginning.

For more information, see the Liberty InstantOn startup for cloud native Java applications blog post.

Jakarta EE 10 Updates

With the 22.0.0.11-beta release, Open Liberty adds four more Jakarta EE 10 features: Mail 2.1, Servlet 6.0, Connectors 2.1 and Persistance 3.1. These four features join the Jakarta EE 10 features from previous beta releases, including those that make up the Jakarta EE 10 Core Profile. To review all the previous beta content, take a look at the recent beta blog posts.

Set any cookie attribute (Jakarta Servlet 6.0)

The Open Liberty Jakarta Servlet 6.0 (servlet-6.0) feature is an implementation of the Jakarta EE 10 Servlet 6.0 specification. It includes a number of new features, specification clarifications, and deprecation features.

Before Jakarta Servlet 6.0, only a few specific methods could be set for an application’s cookie attributes. This meant that an application could not easily set a new attribute, such as the recent browser security SameSite attribute.

One of the new features in Jakarta Servlet 6.0 is the ability to set any attribute using a cookie’s setAttribute method. In addition, Jakarta Servlet 6.0 also introduces some new request APIs to aid the application’s debugging. Application developers can track or refer to a request using the ServletRequest() getRequestId() method or obtain details of the network connection that is being used by the request by calling ServletRequest() getServletConnection() method.

You can enable the feature by adding servlet-6.0 to your server.xml:

  <featureManager>
    <feature>servlet-6.0</feature>
  </featureManager>

For more information, refer to the Jakarta Servlet 6.0 Specification and Javadocs.

Simpler Jakarta Mail code compilation (Jakarta Mail 2.1)

Jakarta Mail 2.1 support allows your Jakarta EE 10 applications to send, read, and edit E-Mail from mail servers via the Jakarta Mail APIs.

The biggest change to the Jakarta Mail 2.1 specification is the removal of the direct dependency of the specification APIs on the reference implementation. This means that, in certain cases, there is no longer a need to compile your Jakarta Mail code against both the specification and the reference implementation (provided you aren’t making any direct calls to the reference implementation in your code).

To facilitate this improvement, Jakarta Mail 2.1 also introduces the jakarta.mail.util.StreamProvider utility interface, which can be easily obtained with the jakarta.mail.Session.getStreamProvider() method. You can then use the StreamProviders instance to obtain encoded/decoded streams for any of the encoding/decoding methods that Jakarta Mail 2.1 supports.

You can enable the feature by adding mail-2.1 to your server.xml:

  <featureManager>
    <feature>mail-2.1</feature>
  </featureManager>

For more information about the Jakarta Mail 2.1 specification, check out the Jakarta Mail project website.

Ensure correctness of data types (Jakarta Connectors 2.1)

Jakarta Connectors standardizes how connectors to various enterprise information systems interact with the container and applications. Jakarta Connectors 2.1 enables you to use the latest release of the Jakarta resource specification in your application.

The main update to Jakarta Connectors in this minor feature version update is the addition of Java generics support to the jakarta.resource.cci.ResourceFactory, jakarta.resource.cci.IndexedRecord, and jakarta.resource.cci.MappedRecord classes. This helps avoid compiler warnings and also helps ensure correctness of data types during development time.

You can enable the feature by adding connectors-2.1 to your server.xml:

  <featureManager>
    <feature>connectors-2.1</feature>
  </featureManager>

All other resourceAdapter configurations within server.xml can remain unchanged for current applications.

You can find out more about this specific update with the following links:

JPQL and Criteria API enhancements (Jakarta Persistence 3.1)

Jakarta Persistence API (JPA) is a richly featured API that provides an object-model approach to persisting, fetching, and modifying data stored on a relational database system. Prior to the introduction of JPA in Java EE 5, in order to interact with database storage, you had to use EJB bean or container managed entities, or raw JDBC.

Jakarta Persistence 3.1 is a minor version update but introduces some great new capabilities. You can now take advantage of the AutoClosable interface, introduced in Java 7, which allows for resources declared in a try-with-resources block to be automatically closed upon the completion of that try block. Other new features include the ability to use fields of type java.lang.UUID as @Id types and enhancements to Java Persistence Query Language (JPQL) and Criteria API.

You can enable the feature by adding persistence-3.1 to your server.xml:

  <featureManager>
    <feature>persistence-3.1</feature>
  </featureManager>

Try it now

To try out these features, just update your build tools to pull the Open Liberty All Beta Features package instead of the main release. The beta works with Java SE 19, Java SE 18, Java SE 17, Java SE 11, and Java SE 8.

If you’re using Maven, here are the coordinates:

<dependency>
  <groupId>io.openliberty.beta</groupId>
  <artifactId>openliberty-runtime</artifactId>
  <version>22.0.0.11-beta</version>
  <type>pom</type>
</dependency>

Or for Gradle:

dependencies {
    libertyRuntime group: 'io.openliberty.beta', name: 'openliberty-runtime', version: '[22.0.0.11-beta,)'
}

Or take a look at our Downloads page.

We welcome your feedback

Let us know what you think on our mailing list. If you hit a problem, post a question on StackOverflow. If you hit a bug, please raise an issue.