使用spring boot和bitronix JTA管理器将XA数据源配置为mysql 8 DB失败,SqlException XAERR_RMERR
我创建了一个SpringBoot2.1.6.RELEASE项目,它依赖于SpringBootStarter数据jpa和SpringBootStarter jta bitronix,并为Mysql DB 8.0.16配置了一个XA数据源 为与之间的占位符值相关而修剪的应用程序属性文件包含以下配置:使用spring boot和bitronix JTA管理器将XA数据源配置为mysql 8 DB失败,SqlException XAERR_RMERR,mysql,spring-data-jpa,jta,xa,bitronix,Mysql,Spring Data Jpa,Jta,Xa,Bitronix,我创建了一个SpringBoot2.1.6.RELEASE项目,它依赖于SpringBootStarter数据jpa和SpringBootStarter jta bitronix,并为Mysql DB 8.0.16配置了一个XA数据源 为与之间的占位符值相关而修剪的应用程序属性文件包含以下配置: spring: datasource: url: jdbc:mysql://<host>:<port>/<dbName> username: &l
spring:
datasource:
url: jdbc:mysql://<host>:<port>/<dbName>
username: <username>
password: <password>
driver-class-name: com.mysql.cj.jdbc.Driver
jpa:
database-platform: org.hibernate.dialect.MySQL8Dialect
hibernate:
ddl-auto: none
jta:
bitronix:
properties:
server-id: <serverid>
免责声明:我正在自我记录我自己的问题,希望能帮助他人,因为令人惊讶的是,这个问题/问题很难解决
通过在github上验证bitronix问题跟踪器,我们不太清楚解决方案是什么,尽管问题已经解决,没有直接的答案
阅读上的bitronix常见问题解答给出了有关此问题的提示,但与Oracle有关,Oracle指的是缺少用户权限
进一步的调查导致了MySQL 8文档页面中关于特权的页面,在下面的部分中有一个特别突出的部分
在MySQL 8.0之前,任何用户都可以执行XA RECOVER语句来
发现未完成事务的XID值,
可能导致用户提交或回滚XA事务
除了启动它的那个人。在MySQL 8.0中,XA RECOVER是
仅允许具有XA_RECOVER_ADMIN权限的用户,该权限
预期仅授予有需要的管理用户
为了它。例如,对于服务器的管理员来说,可能就是这种情况
XA应用程序是否已崩溃,是否需要查找
应用程序启动的未完成事务,以便
向后滚。此权限要求防止用户
发现未完成的已准备XA事务的XID值
除了他们自己。它不会影响的正常提交或回滚
XA事务,因为启动它的用户知道它的XID
因此,我通过MySQL Replace username和host部分中的以下命令向数据源用户添加了所需的权限
将**上的XA_RECOVER_ADMIN授予“用户名”@“%”;
同花顺特权;
通过此更改,spring boot应用程序启动时不会出现任何问题。免责声明:我正在自我记录我自己的问题,希望能帮助他人,因为令人惊讶的是,这个问题/问题很难解决
通过在github上验证bitronix问题跟踪器,我们不太清楚解决方案是什么,尽管问题已经解决,没有直接的答案
阅读上的bitronix常见问题解答给出了有关此问题的提示,但与Oracle有关,Oracle指的是缺少用户权限
进一步的调查导致了MySQL 8文档页面中关于特权的页面,在下面的部分中有一个特别突出的部分
在MySQL 8.0之前,任何用户都可以执行XA RECOVER语句来
发现未完成事务的XID值,
可能导致用户提交或回滚XA事务
除了启动它的那个人。在MySQL 8.0中,XA RECOVER是
仅允许具有XA_RECOVER_ADMIN权限的用户,该权限
预期仅授予有需要的管理用户
为了它。例如,对于服务器的管理员来说,可能就是这种情况
XA应用程序是否已崩溃,是否需要查找
应用程序启动的未完成事务,以便
向后滚。此权限要求防止用户
发现未完成的已准备XA事务的XID值
除了他们自己。它不会影响的正常提交或回滚
XA事务,因为启动它的用户知道它的XID
因此,我通过MySQL Replace username和host部分中的以下命令向数据源用户添加了所需的权限
将**上的XA_RECOVER_ADMIN授予“用户名”@“%”;
同花顺特权;
通过此更改,spring启动应用程序启动时不会出现任何问题。使用WildFly 17和MySQL 8以及XA数据源,我们每两分钟记录一次ARJUNA016027和ARJUNA016009警告,尽管应用程序启动正常。授予XA数据源用户XA_RECOVER_ADMIN角色使其消失。使用WildFly 17和MySQL 8与XA数据源,我们每两分钟记录一次ARJUNA016027和ARJUNA016009警告,尽管应用程序正常启动。将XA_RECOVER_ADMIN角色授予XA数据源用户会使它们消失。
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Unsatisfied dependency expressed through method 'entityManagerFactory' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'entityManagerFactoryBuilder' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Unsatisfied dependency expressed through method 'entityManagerFactoryBuilder' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaVendorAdapter' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.orm.jpa.JpaVendorAdapter]: Factory method 'jpaVendorAdapter' threw exception; nested exception is bitronix.tm.resource.ResourceConfigurationException: cannot create JDBC datasource named dataSource
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'entityManagerFactoryBuilder' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Unsatisfied dependency expressed through method 'entityManagerFactoryBuilder' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaVendorAdapter' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.orm.jpa.JpaVendorAdapter]: Factory method 'jpaVendorAdapter' threw exception; nested exception is bitronix.tm.resource.ResourceConfigurationException: cannot create JDBC datasource named dataSource
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaVendorAdapter' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.orm.jpa.JpaVendorAdapter]: Factory method 'jpaVendorAdapter' threw exception; nested exception is bitronix.tm.resource.ResourceConfigurationException: cannot create JDBC datasource named dataSource
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.orm.jpa.JpaVendorAdapter]: Factory method 'jpaVendorAdapter' threw exception; nested exception is bitronix.tm.resource.ResourceConfigurationException: cannot create JDBC datasource named dataSource
Caused by: bitronix.tm.resource.ResourceConfigurationException: cannot create JDBC datasource named dataSource
Caused by: bitronix.tm.recovery.RecoveryException: failed recovering resource dataSource
Caused by: com.mysql.cj.jdbc.MysqlXAException: XAER_RMERR: Fatal error occurred in the transaction branch - check your data for consistency
Caused by: java.sql.SQLException: XAER_RMERR: Fatal error occurred in the transaction branch - check your data for consistency