MDB onMessage因关闭的JDBC连接而失败

时间:2017-10-02 19:15:39

标签: jdbc xa jboss-eap-7 jboss-mdb

在JBoss eap 7.0上运行应用程序。我有一个MDB,它还引用了一个XA数据源(oracle)来保存数据。经过很长一段时间没有用(几个小时)后,接下来的onMessage调用写入DB,得到错误

    org.hibernate.exception.GenericJDBCException: Unable to acquire JDBC Connection


    Caused by: java.sql.SQLException: javax.resource.ResourceException: 
IJ000457: Unchecked throwable in managedConnectionReconnected() 
cl=org.jboss.jca.core.connectionmanager.listener.TxConnectionListener@178ff38
2[state=DESTROYED managed 
connection=org.jboss.jca.adapters.jdbc.xa.XAManagedConnection@70289860 connection handles=0 lastReturned=1506796773697 lastValidated=1506796773525 lastCheckedOut=1506947349429 trackByTx=false 
pool=org.jboss.jca.core.connectionmanager.pool.strategy.OnePool@5968abc8 
mcp=SemaphoreConcurrentLinkedQueueManagedConnectionPool@83405c5[pool=HIF-
BannerPU] 
xaResource=XAResourceWrapperImpl@2168086b[xaResource=org.jboss.jca.adapters.j
dbc.xa.XAManagedConnection@70289860 pad=false overrideRmValue=null 
productName=Oracle productVersion=Oracle Database 12c Enterprise Edition 
Release 12.2.0.1.0 - 64bit Production jndiName=java:/jdbc/HIF-BannerPU] 
txSync=null

我应该设置validate-on-match = true,还是有更好的方法来确保池连接有效且有效?

更新:将配置更改为:

                <validation>
                    <validate-on-match>true</validate-on-match> 
                    <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.Or‌​acleValidConnectionC‌​hecker"/>
                    <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.Or‌​acleExceptionSorter" />
                </validation> 
                <xa-pool>
                    <is-same-rm-override>false</is-same-rm-override>
                    <no-tx-separate-pools />
                </xa-pool>  

仍然出现错误。

1 个答案:

答案 0 :(得分:1)

是连接池验证设置对于所有数据源都是必需的:

<validation> 

<validate-on-match>true</validate-on-match> <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.Or‌​acleValidConnectionC‌​hecker"></valid-conn‌​ection-checker> 

<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.Or‌​acleExceptionSorter"‌​></exception-sorter> 

</validation> 

同时验证每个特定于Oracle(https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.0/html-single/configuration_guide/#example_oracle_xa_datasource)所涉及的每个xa-datasource中是否显式声明了 is-same-rm-override和no-tx-separate-pools 元素

<xa-pool> ... 
<is-same-rm-override>false</is-same-rm-override> 
<no-tx-separate-pools /> 
</xa-pool>