Skip to content
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

Fix PostgreSQL XA mode in native images #29787

Merged
merged 1 commit into from Dec 13, 2022

Conversation

imperatorx
Copy link
Contributor

@imperatorx imperatorx commented Dec 11, 2022

When using XA transactions in native images with PostgreSQL, an additional reflective items needs to be registered, otherwise the setUser() and setPassword() on the XA datasource is not recognized, and quarkus cannot connect to postgres.

Reproduce: quarkus.datasource.jdbc.transactions=xa and generate a native image, use postgres with standard password authentication, application will fail to connect as username and password are missing from the connect.

When this is not set to XA, the bug is not occuring, as the XA datasource is not used.

@imperatorx imperatorx changed the title Fix XA mode in native images Fix PostgreSQL XA mode in native images Dec 11, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Dec 12, 2022

Failing Jobs - Building 585a7d9

Status Name Step Failures Logs Raw logs
✔️ JVM Tests - JDK 11
✔️ JVM Tests - JDK 17
JVM Tests - JDK 17 MacOS M1 Set up runner ⚠️ Check → Logs Raw logs
✔️ JVM Tests - JDK 18

Copy link
Member

@gsmet gsmet left a comment

Choose a reason for hiding this comment

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

Looks good, thanks. Let's get this in.

@@ -19,6 +19,9 @@ void build(BuildProducer<ReflectiveClassBuildItem> reflectiveClass) {
//We register it for the sake of other users.
final String driverName = "org.postgresql.Driver";
reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, driverName));

// Needed when quarkus.datasource.jdbc.transactions=xa for the setting of the username and password
reflectiveClass.produce(new ReflectiveClassBuildItem(false, true, false, "org.postgresql.ds.common.BaseDataSource"));
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we should have a better infrastructure to push the classes to the JDBC build item and get the JDBC infrastructure do the work. But maybe let's wait to have another similar case before doing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants