0
我正在嘗試使用SQL Server和Sybase連接的Jtds驅動程序執行PoolingDataSource。將Bitronix與Jtds驅動程序集成
protected DataSource dataSource() throws Exception {
// Create pool datasource
final PoolingDataSource poolingDataSource = new PoolingDataSource();
poolingDataSource.setClassName("bitronix.tm.resource.jdbc.lrc.LrcXADataSource");
poolingDataSource.setMaxPoolSize(20);
poolingDataSource.setUniqueName(getDataSourceProperty().getUserName());
poolingDataSource.setAllowLocalTransactions(true);
poolingDataSource.setAutomaticEnlistingEnabled(true);
poolingDataSource.setShareTransactionConnections(false);
final Properties properties = new Properties();
properties.put("driverClassName", getDataSourceProperty().getDriverClassName());
properties.put("url", getDataSourceProperty().getUrl());
properties.put("user", getDataSourceProperty().getUserName());
properties.put("password", DataSourceSecureIdentity.decode(getDataSourceProperty().getPassword()));
poolingDataSource.setDriverProperties(properties);
return poolingDataSource;
}
一旦服務器啓動它表明:
Caused by: bitronix.tm.internal.BitronixSystemException: cannot enlist more than one non-XA resource, tried enlisting an XAResourceHolderState with uniqueName=xxx XAResource=a JDBC LrcXAResource in state NO_TX with XID null, already enlisted: an XAResourceHolderState with uniqueName=xxx2 XAResource=a JDBC LrcXAResource in state STARTED (started) with XID a Bitronix XID [7465737465000000001757A2D000000005 : 7465737465000000001757A70A00000006]
at bitronix.tm.internal.XAResourceManager.enlist(XAResourceManager.java:107) ~[btm-2.1.4.jar:2.1.4]
at bitronix.tm.BitronixTransaction.enlistResource(BitronixTransaction.java:130) ~[btm-2.1.4.jar:2.1.4]
at bitronix.tm.resource.common.TransactionContextHelper.enlistInCurrentTransaction(TransactionContextHelper.java:69) ~[btm-2.1.4.jar:2.1.4]
at bitronix.tm.resource.jdbc.JdbcConnectionHandle.enlistResource(JdbcConnectionHandle.java:85) ~[btm-2.1.4.jar:2.1.4]
... 93 common frames omitted
org.springframework.transaction.UnexpectedRollbackException: JTA transaction unexpectedly rolled back (maybe due to a timeout); nested exception is bitronix.tm.internal.BitronixRollbackException: transaction was marked as rollback only and has been rolled back
at org.springframework.transaction.jta.JtaTransactionManager.doCommit(JtaTransactionManager.java:1024)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:761)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:730)
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:485)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:291)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
我讀我只能有一個非XA數據源,但如果LrcXADataSource類包裝數據源爲什麼會發生?
有沒有辦法通知Jtds Driver關於XA選項?