back to all blogsSee all blog posts

MicroProfile 5, MicroProfile Rest Client 3.0 and JPA enhancements in Open Liberty 22.0.0.1-beta

image of author
Ryan Storey on Nov 30, 2021

Open Liberty 22.0.0.1-beta offers MicroProfile 5.0, which includes MicroProfile Rest Client 3.0 and aligns with Jakarta EE 9.1. This beta release also introduces the ability to declare "default" JPA persistence properties.

For 22.0.0.1-beta, there is a single beta package for Open Liberty:

  • All Beta Features: this package contains all Open Liberty beta features and GA features and functions.

This means that you can try out our in-development Open Liberty features by just adding the relevant coordinates to your build tools.

If you give the beta package a try, let us know what you think.

All Beta Features package

The All Beta Features package includes the following beta features and enhancements:

MicroProfile 5.0

MicroProfile 5.0 enables applications to use MicroProfile APIs together with Jakarta EE 9.1. MicroProfile 5.0 does not provide any other functional updates except aligning with Jakarta EE 9.1. MicroProfile 5.0 includes the following features:

  • Config 3.0

  • Fault Tolerance 4.0

  • Rest Client 3.0

  • Health 4.0

  • Metrics 4.0

  • Open Tracing 3.0

  • Open API 3.0

  • JWT propagation 2.0.

This beta driver will be used as a compatible implementation for releasing MicroProfile 5.0.

Include the following in the server.xml to enable the MicroProfile 5.0 feature in Open Liberty:

<featureManager>
    <feature>microProfile-5.0</feature>
</featureManager>

Alternatively, you can enable the individual MicroProfile features that you need, for example:

<featureManager>
    <feature>mpOpenTracing-3.0</feature>
</featureManager>

For more information about this update, check out the MicroProfile 5.0 Release on GitHub.

MicroProfile Rest Client 3.0

MicroProfile Rest Client is an API that helps developers to write type-safe interfaces that abstract and invoke remote RESTful services. This is the 3.0 release of MicroProfile Rest Client, and it adds support for Jakarta EE 9.1 technologies. From a developer’s perspective, the only change from the previous release (2.0) is the package space name change of Jakarta packages from javax. to jakarta.. However, another change is that the Open Liberty implementation has changed from Apache CXF to RESTEasy - this change brings with it some behavior and property changes (most of which are already documented as differences between jaxrs-2.1 and restfulWS-3.0).

To use this new feature, you would need to add mpRestClient-3.0 to the featureManager element in the server.xml. The code should be similar to previous versions of MP Rest Client, but the packages should change from javax. to jakarta..

<featureManager>
    <feature>mpRestClient-3.0</feature>
</featureManager>

For more information, check out:

Define JPA persistence properties at server scope

This new JPA enhancement adds the ability to declare "default" JPA persistence properties to all container-managed persistence contexts as a Liberty server.xml configuration.

Previously if a persistence property needed to be set for all persistence.xml configuration files you would manually update all persistence.xml files in all applications. This could end up requiring hundreds of manual updates and/or rebuilding of applications. With this enhancement you can specify persistence properties in the server.xml that will propagate to all container-managed persistence units for applications installed on that server.

To start using the new feature, add the <defaultProperties> configuration element to the <jpa> configuration in your server.xml file. Specify the persistence properties that you want to apply to all container-managed persistence units, as shown in the following examples:

Example 1:
<server>
    <featureManager>
        <feature>persistenceContainer-3.0</feature>
    </featureManager>

    <jpa defaultPersistenceProvider="org.hibernate.jpa.HibernatePersistenceProvider">
        <defaultProperties>
            <property name="javax.persistence.lock.timeout" value="4000"/>
            <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle12cDialect"/>
        </defaultProperties>
    </jpa>
</server>
Example 2:
<server>
    <featureManager>
        <feature>jpa-2.1</feature>
    </featureManager>

    <jpa>
        <defaultProperties>
            <property name="javax.persistence.lock.timeout" value="12345"/>
            <property name="eclipselink.cache.shared.default" value="false"/>
        </defaultProperties>
    </jpa>
</server>

Technical description

These defaultProperties are integration-level persistence properties that are supplied to the specified persistence provider when the PersistenceProvider.createContainerEntityManagerFactory method is called by the JPA Container.

According to the JPA specification (3.4.4.3):

If the same property or hint is specified more than once, the following order of overriding applies, in order of decreasing precedence:
  • argument to method of EntityManager, Query, or TypedQuery interface
  • specification to NamedQuery (annotation or XML)
  • argument to createEntityManagerFactory method
  • specification in persistence.xml

These defaultProperties persistence property values override any properties with the same name that are specified in a persistence.xml file. However, property values specified through PersistenceContext annotation, or the persistence-context-ref deployment descriptor element, or Query Hints property will override these defaultProperties.

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 17, Java SE 11, or 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.1-beta</version>
  <type>pom</type>
</dependency>

Or for Gradle:

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

Or take a look at our Downloads page.

Jakarta EE 9.1 Beta Features

Are you looking for our regular section regarding Jakarta EE 9.1 Beta feature updates? Well good news, as of 21.0.0.12 the Jakarta EE 9.1 features are now out of beta and fully supported. That means that you can either use them in the official 21.0.0.12 release, or continue to use them in the beta 22.0.0.1-beta package. Just as before, you can enable the individual features you want or you can just add the Jakarta EE 9.1 convenience feature to enable all of the Jakarta EE 9.1 beta features at once:

  <featureManager>
    <feature>jakartaee-9.1</feature>
  </featureManager>

Or you can add the Web Profile convenience feature to enable all of the Jakarta EE 9.1 Web Profile beta features at once:

  <featureManager>
    <feature>webProfile-9.1</feature>
  </featureManager>

Your feedback is welcomed

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.

Tags