1

On Docker Image open-liberty:22.0.0.1-full-java17-openj9 with the following activated features:

<featureManager>
  <feature>persistence-3.0</feature>
  <feature>localConnector-1.0</feature>
  <feature>microProfile-5.0</feature>
  <feature>beanValidation-3.0</feature>
</featureManager>

and the javax namespace, it was possible to create an TransactionManager via the api dependency

  compileOnly "com.ibm.websphere.appserver.api:com.ibm.websphere.appserver.api.transaction:1.1.60"

in the following way:

package de.xxx.xxx;

import com.ibm.tx.jta.TransactionManagerFactory;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.inject.Produces;
import javax.transaction.TransactionManager;

@RequestScoped
public class TransactionManagerProducer {

@Produces
 public TransactionManager produce() {
  return TransactionManagerFactory.getTransactionManager();
 }
}

We are moving to JakartaEE9 and this one API dependency seems not to have an equivalent for the jakarta.* namespace, so that this is not compiling:

package de.xxx.xxx;

import com.ibm.tx.jta.TransactionManagerFactory;
import jakarta.enterprise.context.RequestScoped;
import jakarta.enterprise.inject.Produces;
import jakarta.transaction.TransactionManager;

@RequestScoped
public class TransactionManagerProducer {

@Produces
 public TransactionManager produce() {
  return TransactionManagerFactory.getTransactionManager();
 }
}

In the openliberty zip, see https://repo1.maven.org/maven2/io/openliberty/openliberty-runtime/22.0.0.1/openliberty-runtime-22.0.0.1.zip an equivalent implementation for

wlp\dev\api\ibm\com.ibm.websphere.appserver.api.transaction_1.1.60.jar  (javax.*)

is available here:

wlp\dev\api\ibm\io.openliberty.transaction_1.1.60.jar  (jakarta.*)

But I can't seem to find the proper API for the io.openliberty.transaction package. Does anyone know how to access the TransactionManagerFactory? Any help is appreciated.

--- UPDATE: Until the API package is available I chose to create the TransactionManager via reflection:

package de.xxx.xxx;

import jakarta.enterprise.context.RequestScoped;
import jakarta.enterprise.inject.Produces;
import jakarta.transaction.TransactionManager;
import java.lang.reflect.InvocationTargetException;

@RequestScoped
public class TransactionManagerProducer {

@Produces
public TransactionManager produce() {
try {
  return (TransactionManager)
      Class.forName("com.ibm.tx.jta.TransactionManagerFactory")
          .getDeclaredMethod("getTransactionManager")
          .invoke(null);
} catch (ClassNotFoundException
    | NoSuchMethodException
    | InvocationTargetException
    | IllegalAccessException e) {
  throw new IllegalStateException("TransactionManager could not be created");
}

} }

schowave
  • 306
  • 2
  • 12

2 Answers2

1

The problem here is that the API and SPI bundles that start with io.openliberty have not been publishing to DHE and maven as part of the Liberty publishing tasks that run when a new version is released. We are looking to have this resolved with 22.0.0.2 which is scheduled to be available tomorrow if we don't run into any additional snags and the io.openliberty publishing goes well.

Jared Anderson
  • 249
  • 1
  • 5
  • At least some of the publishing work is done for 22.0.0.2 and you will find that the API bundle is now available for 22.0.0.2: https://repo.maven.apache.org/maven2/io/openliberty/api/io.openliberty.transaction/1.1.61/ – Jared Anderson Feb 15 '22 at 14:24
  • In the corresponding jar file, there are still javax.* Namespaces referenced in the ExtendedTransactionManager class. Is this by accident? – schowave Feb 16 '22 at 10:48
  • If you are talking about a javax.transaction.xa package reference, that package still in Java SE and not changed to jakarta.transaction.xa in the Jakarta Transaction 2.0 specification since it is a Java SE package so it will still use javax. – Jared Anderson Feb 17 '22 at 18:46
  • No, I am talking about the class \com\ibm\tx\jta\ExtendedTransactionManager.class: This class still contains the following import: import javax.transaction.TransactionManager; and that was moved to jakarta.* – schowave Feb 21 '22 at 07:50
  • You are correct. What got published to maven is wrong. What is in the install image is correct though. I will look into why that is. – Jared Anderson Feb 22 '22 at 11:56
0

For 22.0.0.3, the api is published finally correctly here: https://repo.maven.apache.org/maven2/io/openliberty/api/io.openliberty.transaction/1.1.62/

schowave
  • 306
  • 2
  • 12
  • I was able to get in a fix for 22.0.0.3 for this problem. Now that the release is available, I am able to state it is fixed in 22.0.0.3 and later. – Jared Anderson Mar 16 '22 at 21:23