hibernate-5.4.0-upgrade-causes-ij000453-无法获得用于Java的托管连接:/ xa-Datasource

时间:2019-05-08 10:29:10

标签: java spring hibernate wildfly

我们有一个运行在Java 8,Wildfly 10,Hibernate 5.0.10和Spring 4.3.11上的应用程序。

我们已将系统升级到OpenJDK11,Wildfly 16和Spring 5.1.0,一切都按预期工作。

但是,当我们尝试将Hibernate升级到5.3.6 / 7 / 5.4.0时,我们面临着数据库连接方面的问题。

下面是我可以共享的日志中的语句。

Unable to acquire JDBC Connection at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:47)

org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.getPhysicalConnection(LogicalConnectionManagedImpl.java:136)
java.sql.SQLException: javax.resource.ResourceException: IJ000453: Unable to get managed connection for java:/RND_XA_DS
    at org.jboss.ironjacamar.jdbcadapters@1.4.12.Final//org.jboss.jca.adapters.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:146)
    at org.jboss.as.connector@16.0.0.Final//org.jboss.as.connector.subsystems.datasources.WildFlyDataSource.getConnection(WildFlyDataSource.java:64)
    at 
 javax.resource.ResourceException: IJ000655: No managed connections available within configured blocking timeout (30000 [ms])
    at org.jboss.ironjacamar.impl@1.4.12.Final//org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreConcurrentLinkedDequeManagedConnectionPool.getConnection(SemaphoreConcurrentLinkedDequeManagedConnectionPool.java:570)
    at org.jboss.ironjacamar.impl@1.4.12.Final//org.jboss.jca.core.connectionmanager.pool.AbstractPool.getTransactionNewConnection(AbstractPool.java:714)
    at org.jboss.ironjacamar.impl@1.4.12.Final//org.jboss.jca.core.connectionmanager.pool.AbstractPool.getConnection(AbstractPool.java:613)
    at org.jboss.ironjacamar.impl@1.4.12.Final//org.jboss.jca.core.connectionmanager.AbstractConnectionManager.getManagedConnection(AbstractConnectionManager.java:624)

1。wildfly的standalone-full-ha.xml中的最大池大小从35增加到100。

2。修改了SessionFactory cfg属性,更改了具有Hibernate 5.4.0支持的属性的事务配置

3。尝试按照如下方式在standalone-full-ha.xml中尝试所有可用的刷新策略值: (https://docs.jboss.org/hibernate/orm/5.4/userguide/html_single/Hibernate_User_Guide.html#flushing

4。尝试使用SessionFactory(https://docs.jboss.org/hibernate/orm/5.4/userguide/html_single/Hibernate_User_Guide.html#database-connection-handling)的所有可用hibernate.connection.handling_mode

5。经过上述更改,应用程序EAR未能成功部署。此时所有问题都很普遍。

6。有助于改变的变化 a)persistence.xml中的事务配置,将属性hibernate.transaction.jta.platform更改为JBossAS b)在代码中打开的任何地方都关闭了会话。

7。将Oracle Processs增加到800。

8。将OJdbc驱动程序更新为ojdbc8。

<xa-datasource jndi-name="java:/RND_XA_DS" pool-name="XYZ" enabled="true" spy="true" use-ccm="false">
                    <xa-datasource-property name="URL">
                        jdbc:oracle:thin:@localhost:1521:xe
                    </xa-datasource-property>
                    <driver>Oracle11G</driver>
                    <xa-pool>
                        <min-pool-size>10</min-pool-size>
                        <max-pool-size>35</max-pool-size>
                        <prefill>true</prefill>
                        <flush-strategy>Gracefully</flush-strategy>
                        <is-same-rm-override>false</is-same-rm-override>
                        <interleaving>false</interleaving>
                        <pad-xid>false</pad-xid>
                        <wrap-xa-resource>false</wrap-xa-resource>
                    </xa-pool>
                    <security>
                        <security-domain>XYZ</security-domain>
                    </security>
                    <validation>
                        <check-valid-connection-sql>select 1 from dual</check-valid-connection-sql>
                        <validate-on-match>false</validate-on-match>
                        <background-validation>false</background-validation>
                    </validation>
                    <statement>
                        <share-prepared-statements>false</share-prepared-statements>
                    </statement>
                </xa-datasource>
####### SESSIONFACTORY属性
<property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">
                    ${SESSIONFACTORY.DIALECT}
                </prop>
                <prop key="hibernate.show_sql">${SESSIONFACTORY.SHOWSQL}</prop>
                <prop key="hibernate.current_session_context_class">jta</prop>
                <prop key="hibernate.transaction.jta.platform">JBossAS
                </prop>
                <prop key="hibernate.transaction.coordinator_class">jta</prop>
                <prop key="hibernate.connection.handling_mode">DELAYED_ACQUISITION_AND_RELEASE_AFTER_TRANSACTION</prop>
                <prop key="jta.UserTransaction">${USER_TRANSACTION}</prop>
            </props>
        </property>

EAR已成功部署在Wildfly上,并且在与数据库交互的应用程序上执行的任何操作均成功。很快,Hibernate就会开始抛出“无法获得托管连接”

0 个答案:

没有答案