Skip to main content
Redhat Developers  Logo
  • Products

    Platforms

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat AI
      Red Hat AI
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • View All Red Hat Products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat Developer Hub
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat OpenShift Local
    • Red Hat Developer Sandbox

      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Secure Development & Architectures

      • Security
      • Secure coding
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • Product Documentation
    • API Catalog
    • Legacy Documentation
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Open Liberty 20.0.0.5 brings updates to EJB persistent timers coordination and failover across members

May 13, 2020
Tom Jennings
Related topics:
ContainersJavaKubernetesMicroservices
Related products:
Red Hat Enterprise Linux

Share:

    In Open Liberty 20.0.0.5, you can now configure failover for Enterprise JavaBeans (EJB) persistent timers, load Java Authentication and Authorization Service (JAAS) classes directly from the resource adapter, format your logs to JSON or dev, and specify which JSON fields to leave out of your logs. In this article, we will discuss each of these features and how to implement them.

    View the list of fixed bugs in Open Liberty's GitHub Issues listing.

    If you're interested in what's coming soon in Open Liberty, take a look at our current development builds, which include GraphQL with Open Liberty.

    Run your apps using 20.0.0.5

    If you're using Maven, here are the coordinates for running your apps:

    <dependency>
        <groupId>io.openliberty</groupId>
        <artifactId>openliberty-runtime</artifactId>
        <version>20.0.0.5</version>
        <type>zip</type>
    </dependency>

    Or for Gradle:

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

    Or if you're using Docker:

    FROM open-liberty

    You can also take a look at our Downloads page or ask a question on Stack Overflow.

    EJB persistent timers coordination and failover across members

    With Open Liberty 20.0.0.5, developers can add a configurable attribute to the EJB Persistent Timer feature. The new attribute sets a maximum amount of time allowed for a persistent timer to complete before another server can take over and run the timer instead.

    Prior to this feature, coordination of automatic EJB persistent timers across multiple Open Liberty servers was limited to ensuring that only a single instance of a timer was created across all servers by configuring the EJB timer service on each to persist timers to the same database. This setup caused a single timer instance to be created on one of the servers but without the ability to go to another server if the original server stops or crashes. To enable failover, this feature adds a new configurable attribute, missedTaskThreshold, which specifies the maximum amount of time that you want to allow for the execution of a persistent timer to complete before allowing another server to take over and run it instead.

    Enable the EJB persistent timers feature—or another feature that implicitly enables it, such as ejb-3.2—and configure it to use a data source. In this example, we configure the feature to use the Java EE or Jakarta EE default data source. This much configuration is required regardless of whether you want to enable failover or not.

    To add the feature to the server.xml:

    <server>
      <featureManager>
        <feature>ejbPersistentTimer-3.2</feature>
        <feature>jdbc-4.2</feature>
        ... other features
      </featureManager>
    
      <dataSource id="DefaultDataSource">
        <jdbcDriver libraryRef="OraLib"/>
        <properties.oracle URL="jdbc:oracle:thin:@//localhost:1521/EXAMPLEDB"/>
        <containerAuthData user="dbuser" password="dbpwd"/>
      </dataSource>
      <library id="OraLib">
        <file name="${shared.resource.dir}/jdbc/ojdbc8.jar" />
      </library>
    
      <!-- The following enables failover for persistent timers -->
      <persistentExecutor id="defaultEJBPersistentTimerExecutor" missedTaskThreshold="5m"/>
    
      ...
    </server>

    Load JAAS LoginModules from resource adapters

    Open Liberty supports JAAS LoginModules for configuring access to J2EE Connector Architecture (JCA)-managed resources. In general, JAAS LoginModules are packaged as a shared library and configured for Open Liberty. Sometimes a JAAS LoginModule is packaged as part of a JCA ResourceAdapter. In the past, to use these JAAS LoginModules, the classes from the ResourceAdapter had to be extracted and configured as a shared library. With this new feature, the jaasLoginModule can now load the classes directly from the resource adapter, simplifying the configuration. Before, it was necessary to package (or repackage) JAAS custom login modules into a separate shared library to configure Open Liberty to use them.

    Enable the AppSecurity and JCA features and configure a resource adapter. Use the classProviderRef attribute on the jaasLoginModule element to reference the id of the resource adapter:

    <server>
      <featureManager>
        <feature>appSecurity-2.0</feature>
        <feature>jca-1.7</feature>
        ... other features
      </featureManager>
    
      <resourceAdapter id="eciResourceAdapter" location="${shared.resource.dir}/cicseci.rar"/>
    
      <!-- classProviderRef indicates that the login module class is found in the resource adapter -->
      <jaasLoginModule id="identityProp" controlFlag="REQUIRED"
          className="com.ibm.ctg.security.idprop.LoginModule"
          classProviderRef="eciResourceAdapter">
        <options propIdentity="Caller"/>
      </jaasLoginModule>
    
      <jaasLoginContextEntry id="CTGEntry" loginModuleRef="identityProp" name="CTGEntry"/>
    
      <connectionFactory id="cf1" jndiName="eis/cf1" jaasLoginContextEntryRef="CTGEntry">
        <properties.eciResourceAdapter ConnectionUrl="tcp://localhost" portNumber="2006" serverName="MYSERVER"/>
      </connectionFactory>
    
      ...
    </server>

    The same approach can be used for JAAS custom login modules that are packaged within an application. Set the classProviderRef to point to the id of the application, webApplication, or enterpriseApplication element that contains the login module class. When packaging JAAS custom login modules within an application, include the login module within one of the following places:

    • Within a top-level JAR of the enterprise application.
    • Within a resource adapter module of the enterprise application.
    • Within the web module of the enterprise application.
    • Within an EJB module of the enterprise application.
    • Within a web application.

    It should be noted that JAAS custom login modules require the use of a resource reference with container-managed authentication.

    You can find out more about Configuring a JAAS custom login module for Liberty.

    Open Liberty console logging

    Open Liberty console logging now has the ability to format logs with date and timestamps and other relevant information. Users can apply different formats, such as JSON or dev, to the server logs that appear in their console.log file by using the consoleFormat logging attribute in the server logging configuration. The dev format is the default format and shows messages in a basic format, with no timestamp or any other relevant information. It only shows the message log level and the message itself.

    For example:

    consoleFormat=dev (default)
    [AUDIT ] CWWKE0001I: The server server1 has been launched.

    This feature introduces a new option called simple for the consoleFormat logging server configuration attribute. This new option configures Open Liberty to output logs in the same simple format used in the message.log file, with date/timestamps and other relevant information, to the console.log file or to the console (console.log/standard-out).

    For example:

    consoleFormat=simple
    [25/11/19 10:02:30:080 EST] 00000001 com.ibm.ws.kernel.launch.internal.FrameworkManager A CWWKE0001I: The server server1 has been launched.

    To configure the Liberty logs to output logs in the new simple console format, you just have to set the following logging server configuration in the server.env, bootstrap.properties, or in the server.xml:

    server.env

    WLP_LOGGING_CONSOLE_FORMAT=simple

    bootstrap.properties

    com.ibm.ws.logging.console.format=simple

    server.xml

    WLP_LOGGING_CONSOLE_FORMAT=simple

    Omit specified fields from JSON logging output

    In Open Liberty, users can format their server logs in JSON format. When logs are in JSON format, users have to specify the sources (message, trace, accessLog, ffdc, audit) they want to send to messages.log or console.log/standard-out.

    Users can now specify the JSON fields they want to omit. This feature adds an option for users to omit JSON fields in the JSON logging process. The option to omit JSON field names in Open Liberty is extremely useful, as users might not want certain default fields provided by Open Liberty in their JSON output. Undesired fields add to the size of the records, which wastes network I/O during record transmissions and wastes space in downstream log aggregation tools. Now, users can choose to emit only the fields they need so they can send to downstream log aggregation tools without using more space and I/O than necessary. For example, someone who's running Open Liberty in Docker containers, with a single server in each container, might not want to include the JSON fields that represent the server name and user directory.

    This attribute was initially used only for renaming field names. To rename a JSON field name, the format is specified as source:defaultFieldName:newFieldName or defaultFieldName:newFieldName. To omit defaultFieldName, leave newFieldName empty. For example, to omit a field for all sources, use the defaultFieldName: format. To omit a field for a specific source, use the source:defaultFieldName: format, where source is the source you want to specify, such as message, trace, accessLog, ffdc, or audit.

    An example of omitting JSON fields by adding the following to bootstrap.properties:
    com.ibm.ws.logging.json.field.mappings=trace:ibm_userDir: ,ibm_datetime:.

    You can find more information by viewing Logging and Trace in the IBM Knowledge Center or the Open Liberty Logging documentation.

    Try Open Liberty 20.0.0.5 in Red Hat Runtimes now

    Open Liberty is part of the Red Hat Runtimes offering. If you're a Red Hat Runtimes subscriber, you can try Open Liberty now.

    Last updated: March 30, 2023

    Recent Posts

    • Profiling vLLM Inference Server with GPU acceleration on RHEL

    • Network performance in distributed training: Maximizing GPU utilization on OpenShift

    • Clang bytecode interpreter update

    • How Red Hat has redefined continuous performance testing

    • Simplify OpenShift installation in air-gapped environments

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2025 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue