简体   繁体   English

Glassfish 4.0可序列化的联合池不适用于Oracle XA事务

[英]Glassfish 4.0 serializable coonection pools not working with Oracle XA transactions

I have a problem that I don't know how solve and researching the net has not helped me much. 我有一个问题,我不知道如何解决和研究网络对我没有多大帮助。 I declare in glassfish 4.0 asadmin console a serializable connection pool and its corresponding resource. 我在glassfish 4.0中声明asadmin控制台为可序列化的连接池及其对应的资源。

create-jdbc-connection-pool --datasourceclassname oracle.jdbc.xa.client.OracleXADataSource --maxpoolsize 8 --isolationlevel serializable --restype javax.sql.XADataSource --property Password=A_DB:User=A_DB:URL="jdbc\:oracle\:thin\:@localhost\:1521\:orcl" ATestPool

create-jdbc-resource --connectionpoolid ATestPool jdbc/ATest

Then inside a stateless bean I build a datasource via jndi as follows: 然后在无状态bean中,我通过jndi如下构建数据源:

InitialContext ic = new InitialContext();
jndiDataSource = (DataSource) ic.lookup("jdbc/ATest");

and I'm getting connection as follows 我得到如下连接

jndiDataSource.getConnection();

Connections are properly obtained and released via finally clauses in each method we they are needed. 可以通过我们需要的每种方法中的finally子句正确获取和释放连接。 However, pairing serializable connection pool with XA data sources seems not to work, as getting first connections throws the following pair of exceptions in the order shown below 但是,将可序列化连接池与XA数据源配对似乎不起作用,因为获取第一个连接会按以下所示顺序抛出以下一对异常

JTS5041: The resource manager is doing work outside a global transaction
oracle.jdbc.xa.OracleXAException
at oracle.jdbc.xa.OracleXAResource.checkError(OracleXAResource.java:1110)

RAR5029:Unexpected exception while registering component 
javax.transaction.SystemException
at com.sun.jts.jta.TransactionImpl.enlistResource(TransactionImpl.java:224)

with the following 与以下

RAR7132: Unable to enlist the resource in transaction. Returned resource to pool. Pool name: [ ATestPool ]]]
RAR5117 : Failed to obtain/create connection from connection pool [ ATestPool ]. Reason : com.sun.appserv.connectors.internal.api.PoolingException: javax.transaction.SystemException]]
RAR5114 : Error allocating connection : [Error in allocating a connection. Cause: javax.transaction.SystemException]]].

Now if the connection pool is recreated without --isolationlevel serializable , then application works fine without any changes into the code. 现在,如果在没有--isolationlevel serializable情况下重新创建连接池,则应用程序可以正常运行,而无需对代码进行任何更改。 Also, if one keeps the isolation parameter and uses non-XA transactions as 另外,如果保留隔离参数并使用非XA交易作为

--datasourceclassname oracle.jdbc.pool.OracleDataSource
--restype javax.sql.DataSource

then again application works without any changes into the code. 然后应用程序再次运行,无需对代码进行任何更改。 I was wondering if anyone could explain to me what could be wrong in the above setup and how to actually make serializable work with XA data sources. 我想知道是否有人可以向我解释上述设置中可能存在的问题以及如何实际使用XA数据源进行可序列化工作。 Thanks. 谢谢。

我认为您需要启用useNativeXA。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM