Skip to content

Add optional module for Jakarta Transactions impl of Jakarta EE 9 Spec #35810

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

linghengqian
Copy link
Member

@linghengqian linghengqian commented Jun 26, 2025

Fixes #26041 .

Changes proposed in this pull request:

  • Add optional module for Jakarta Transactions impl of Jakarta EE 9 Spec. This is an alternative to Migrate from Jakarta EE 8 to Jakarta EE 9 #27976 . The main difference is that the current PR does not switch the JAXB version used by the test suite.
  • shardingsphere-transaction-xa-jakarta basically reuses all the definitions of shardingsphere-transaction-xa, but switches javax.transaction java package to jakarta.transaction java package, and uses a different set of third-party dependencies.
  • It is intentional that the Jakarta EE 8 namespace counterpart org.apache.shardingsphere.transaction.api.TransactionType#XA is still used, because org.apache.shardingsphere:shardingsphere-transaction-xa-jakarta-core and org.apache.shardingsphere:shardingsphere-transaction-xa-jakarta-core cannot be used in the same Maven module at the same time, as the two modules use different versions of the same set of third-party dependencies. Going forward, ShardingSphere Proxy and ShardingSphere Proxy Native should be updated to use the Jakarta Transactions implementation of Jakarta EE 9 Spec. Of course I know that there are new major impacts in General upgrade to Jakarta EE 11 APIs spring-projects/spring-framework#34011 on the Spring Boot 4 milestone. But we should always take it one step at a time, right?
  • Update nativeTest of XA distributed transactions under GraalVM Native Image to Jakarta Transactions impl of Jakarta EE 9 Spec. For third-party frameworks that support GraalVM Native Image integration, such as Spring Boot 3, which have actually already given up support for Jakarta EE 8, it makes sense to switch to Jakarta EE 9 because it is closer to the third-party integration scenario.
  • Unify version management of com.oracle.database.jdbc:ojdbc8.
  • Add GraalVM Reachability Metadata for com.microsoft.sqlserver:mssql-jdbc:12.10.1.jre8. For Improve GraalVM Reachability Metadata and corresponding nativeTest related unit tests #29052 .
  • Bump the MS SQL Server JDBC used in the tests to 12.10.1.jre8. I can't understand why com.microsoft.sqlserver:mssql-jdbc:6.1.7.jre8-preview would depend on Jakarta EE 8's JAXB API.🫠
java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter

	at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:3984)
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:3097)
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$100(SQLServerConnection.java:82)
	at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:3061)
	at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7137)
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2417)
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1999)
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:1668)
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1511)
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:864)
	at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:569)
	at org.testcontainers.containers.JdbcDatabaseContainer.createConnection(JdbcDatabaseContainer.java:287)
	at org.testcontainers.containers.JdbcDatabaseContainer.createConnection(JdbcDatabaseContainer.java:252)
	at org.testcontainers.containers.JdbcDatabaseContainer.waitUntilContainerStarted(JdbcDatabaseContainer.java:192)
	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:492)
	at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:346)
	at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)
	at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:336)
	at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:322)
	at org.testcontainers.jdbc.ContainerDatabaseDriver.connect(ContainerDatabaseDriver.java:134)
	at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:121)
	at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:364)
	at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206)
	at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:476)
	at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561)
	at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)
	at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)
	at org.apache.shardingsphere.infra.database.DatabaseTypeEngine.getStorageType(DatabaseTypeEngine.java:113)
	at org.apache.shardingsphere.infra.database.DatabaseTypeEngine.getProtocolType(DatabaseTypeEngine.java:80)
	at org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabasesFactory.create(ShardingSphereDatabasesFactory.java:80)
	at org.apache.shardingsphere.mode.metadata.factory.init.type.LocalConfigurationMetaDataContextsInitFactory.create(LocalConfigurationMetaDataContextsInitFactory.java:55)
	at org.apache.shardingsphere.mode.metadata.factory.MetaDataContextsFactory.create(MetaDataContextsFactory.java:75)
	at org.apache.shardingsphere.mode.manager.standalone.StandaloneContextManagerBuilder.build(StandaloneContextManagerBuilder.java:52)
	at org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource.createContextManager(ShardingSphereDataSource.java:77)
	at org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource.<init>(ShardingSphereDataSource.java:65)
	at org.apache.shardingsphere.driver.api.ShardingSphereDataSourceFactory.createDataSource(ShardingSphereDataSourceFactory.java:95)
	at org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory.createDataSource(YamlShardingSphereDataSourceFactory.java:136)
	at org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory.createDataSource(YamlShardingSphereDataSourceFactory.java:71)
	at org.apache.shardingsphere.driver.jdbc.core.driver.DriverDataSourceCache.createDataSource(DriverDataSourceCache.java:57)
	at org.apache.shardingsphere.driver.jdbc.core.driver.DriverDataSourceCache.lambda$get$0(DriverDataSourceCache.java:50)
	at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1710)
	at org.apache.shardingsphere.driver.jdbc.core.driver.DriverDataSourceCache.get(DriverDataSourceCache.java:50)
	at org.apache.shardingsphere.driver.ShardingSphereDriver.connect(ShardingSphereDriver.java:57)
	at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:121)
	at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:364)
	at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206)
	at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:476)
	at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561)
	at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)
	at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:81)
	at org.apache.shardingsphere.test.natived.jdbc.databases.SQLServerTest.assertShardingInLocalTransactions(SQLServerTest.java:65)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1597)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1597)
	Suppressed: java.lang.NullPointerException: Cannot invoke "javax.sql.DataSource.getConnection()" because "this.logicDataSource" is null
		at org.apache.shardingsphere.test.natived.jdbc.databases.SQLServerTest.afterEach(SQLServerTest.java:45)
		... 3 more
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.DatatypeConverter
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
	... 54 more

Before committing this PR, I'm sure that I have checked the following options:

  • My code follows the code of conduct of this project.
  • I have self-reviewed the commit code.
  • I have (or in comment I request) added corresponding labels for the pull request.
  • I have passed maven check locally : ./mvnw clean install -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e.
  • I have made corresponding changes to the documentation.
  • I have added corresponding unit tests for my changes.
  • I have updated the Release Notes of the current development version. For more details, see Update Release Note

Copilot

This comment was marked as outdated.

@linghengqian linghengqian force-pushed the jakarta branch 4 times, most recently from 11d1fc3 to 7ec4950 Compare June 27, 2025 06:37
@linghengqian linghengqian marked this pull request as ready for review June 27, 2025 06:38
@linghengqian linghengqian requested a review from Copilot June 27, 2025 06:38
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces an optional Jakarta Transactions implementation for Jakarta EE 9 to support XA in ShardingSphere, updates native test dependencies, and unifies JDBC driver version management.

  • Add new shardingsphere-transaction-xa-jakarta modules (SPI, provider, core) alongside existing XA core.
  • Update pom.xml and test/native/pom.xml to bump MS SQL, Oracle JDBC versions and declare Jakarta BOM properties.
  • Extend tests for Atomikos/Narayana providers and core JTA integration under Jakarta spec.

Reviewed Changes

Copilot reviewed 86 out of 86 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
test/native/pom.xml Added Jakarta EE 9 BOM properties and switched XA core exclusions.
pom.xml Bumped <mssql.version>, added <ojdbc8.version> and test dependency.
kernel/transaction/type/xa-jakarta Introduced Jakarta EE 9–based XA modules (spi, provider, core).
kernel/transaction/type/xa-jakarta/core/src/main/java/.../DataSourceSwapper.java Implemented data source→XADataSource property mapping.
kernel/transaction/type/xa-jakarta/spi/src/main/java/.../SingleXAResource.java Wrapped XAResource with exception mapping stub.
kernel/transaction/type/xa-jakarta/provider/* Added Atomikos and Narayana transaction manager providers/tests.
Comments suppressed due to low confidence (1)

kernel/transaction/type/xa-jakarta/provider/atomikos/src/test/java/org/apache/shardingsphere/transaction/xa/jakarta/atomikos/manager/AtomikosTransactionManagerProviderTest.java:78

  • [nitpick] The test method name assertEnListResource has inconsistent camelCase; consider renaming to assertEnlistResource for readability.
    void assertEnListResource() throws SystemException, RollbackException {

@linghengqian linghengqian added this to the 5.5.3 milestone Jun 27, 2025
@linghengqian linghengqian force-pushed the jakarta branch 12 times, most recently from f849c5e to 749c2ed Compare July 15, 2025 08:00
Copy link
Member Author

@linghengqian linghengqian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Cannot use org.eclipse.transformer:transformer-maven-plugin:0.5.0 because org.eclipse.transformer:transformer-maven-plugin:0.5.0's handling conflicts with the jar-in-test-phase of maven-jar-plugin introduced in graalvm/native-build-tools#727 .

Copy link
Member Author

@linghengqian linghengqian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Cannot use org.eclipse.transformer:transformer-maven-plugin:0.5.0 because org.eclipse.transformer:transformer-maven-plugin:0.5.0's handling conflicts with the jar-in-test-phase of maven-jar-plugin introduced in graalvm/native-build-tools#727 .
  • All the prerequisite issues have been solved based on #36050 .

@linghengqian linghengqian marked this pull request as ready for review July 22, 2025 08:41
@linghengqian linghengqian added this to the 5.5.3 milestone Jul 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Transition from Jakarta EE 8 to Jakarta EE 9
1 participant