我正在使用 postgres、wildfly-swarm、hibernate,并且我的事务是 bean 管理的。
我的 project-defaults.yml 数据源:数据源:部分
Adadawdadsa:
driver-name: postgresql
connection-url: dadadasdadas
user-name: aawdwaasda
password: waddsawdas
jta: true
use-java-context: true
pool-name: awdasdadwaadads
min-pool-size: 10
initial-pool-size: 15
max-pool-size: 40
pool-prefill: false
validate-on-match: true
use-fast-fail: false
connection-checker-class-name: org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLValidConnectionChecker
check-valid-connection-sql: "SELECT 1;"
exception-sorter-class-name: org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLExceptionSorter
connection-properties: CharacterEncoding/ UTF-8 UseUnicode/true
在模拟应用程序和 postgres 之间的连接丢失后(关闭数据库、iptables 丢弃数据包等,然后执行一些请求然后再次启动数据库或清除 iptables 丢弃规则),数据库已启动但 Hibernate/swarm 无法找到连接不再...有人可以告诉我我做错了什么吗?
编辑:添加堆栈跟踪
2017-11-23 15:16:03.180 错误 [PgSinkTask.paymentResultToJPA.0] PgSinkTask.paymentResultToJPA.0:重试提交异常::javax.persistence.PersistenceException:org.hibernate.exception.GenericJDBCException:无法获取 JDBC 连接 2017 -11-23 15:16:03.180 错误 [PgSinkTask.paymentResultToJPA.0] PgSinkTask.paymentResultToJPA.0:重试提交时出现异常:javax.persistence.PersistenceException:org.hibernate.exception.GenericJDBCException:无法在 org 获取 JDBC 连接。 hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1692) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1602) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl. java:1608) 在 org.hibernate.jpa.spi。AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:1171) at com.scheidtbachmann.fcs.idbt.datamart.sink.JPASinkTask.setConnectorStatus(JPASinkTask.java:297) at com.scheidtbachmann.fcs.idbt.datamart.sink.JPASinkTask.errorHandler( JPASinkTask.java:423) 在 com.scheidtbachmann.fcs.idbt.datamart.sink.JPASinkTask.flush(JPASinkTask.java:328) 在 com.scheidtbachmann.fcs.idbt.datamart.sink.JPASinkTask.getRecord(JPASinkTask.java: 182) 在 com.scheidtbachmann.fcs.idbt.datamart.sink.JPASinkTask.run(JPASinkTask.java:144) 在 java.lang.Thread.run(Thread.java:748) 在 org.glassfish.enterprise.concurrent.ManagedThreadFactoryImpl $ManagedThread.run(ManagedThreadFactoryImpl.java:250) 原因:org.hibernate.exception.GenericJDBCException:无法在 org.hibernate.exception.internal 获取 JDBC 连接。StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:47) 在 org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:109) 在 org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java: 95) 在 org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.getPhysicalConnection(LogicalConnectionManagedImpl.java:112) 在 org.hibernate.engine 的 org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:90) .jdbc.internal.StatementPreparerImpl.connection(StatementPreparerImpl.java:47) 在 org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:146) 在 org.hibernate.engine.jdbc.internal.StatementPreparerImpl$声明准备模板。prepareStatement(StatementPreparerImpl.java:172) 在 org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:148) 在 org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1929) 在 org.hibernate .loader.Loader.executeQueryStatement(Loader.java:1898) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1876) at org.hibernate.loader.Loader.doQuery(Loader.java:919) at org. hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:336) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:306) at org.hibernate.loader.Loader.loadEntity(Loader.java:2204) at org .hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:60) 在 org.hibernate.loader.entity.AbstractEntityLoader。load(AbstractEntityLoader.java:50) at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3967) at org.hibernate.event.internal.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:508) at org.hibernate .event.internal.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:478) at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:219) at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java :278) org.hibernate.event.internal.DefaultLoadEventListener.doOnLoad(DefaultLoadEventListener.java:121) org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:89) org.hibernate.internal.SessionImpl。 fireLoad(SessionImpl.java:1129) 在 org.hibernate.internal.SessionImpl.access$2600(SessionImpl.java:164) at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.load(SessionImpl.java:2696) at org.hibernate.internal.SessionImpl.get(SessionImpl.java:980 ) 在 org.hibernate.event.internal.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:170) 在 org.hibernate.event.internal.DefaultMergeEventListener 的 org.hibernate.event.internal.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:290)。 onMerge(DefaultMergeEventListener.java:69) at org.hibernate.internal.SessionImpl.fireMerge(SessionImpl.java:840) at org.hibernate.internal.SessionImpl.merge(SessionImpl.java:822) at org.hibernate.internal.SessionImpl .merge(SessionImpl.java:827) 在 org.hibernate.jpa.spi.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:1161)...省略了 7 个常见框架 原因:java.sql.SQLException:javax.resource.ResourceException:IJ000460:在 org.jboss.jca.adapters.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java: 146) 在 org.jboss.as.connector.subsystems.datasources.WildFlyDataSource.getConnection(WildFlyDataSource.java:66) 在 org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) 在 org .hibernate.internal.AbstractSessionImpl$NonContextualJdbcConnectionAccess.obtainConnection(AbstractSessionImpl.java:386) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:87) ...省略了 39 个常见帧 原因:javax。 resource.ResourceException:IJ000460:在 org.jboss.jca.core.connectionmanager.AbstractConnectionManager.allocateConnection(AbstractConnectionManager.java:747) 的 org.jboss.jca.core.connectionmanager.tx.TxConnectionManagerImpl.getManagedConnection(TxConnectionManagerImpl.java:424) 检查事务时出错org.jboss.jca.adapters.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:138) ... 省略了 43 个常用帧 原因:javax.resource.ResourceException:IJ000459:事务未激活:tx=TransactionImple < ac, BasicAction : 0:ffffc0a83842:6e69d97c:5a16d4f3:18 状态: ActionStatus.ABORTED > at org.jboss.jca.core.connectionmanager.tx.TxConnectionManagerImpl.getManagedConnection(TxConnectionManagerImpl.java:408) ... 省略了 45 个常用帧TxConnectionManagerImpl.getManagedConnection(TxConnectionManagerImpl.java:424) 在 org.jboss.jca.core.connectionmanager.AbstractConnectionManager.allocateConnection(AbstractConnectionManager.java:747) 在 org.jboss.jca.adapters.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java: 138)...省略了 43 个公共帧 原因:javax.resource.ResourceException:IJ000459:事务未激活:tx=TransactionImple < ac,BasicAction:0:ffffc0a83842:6e69d97c:5a16d4f3:18 状态:ActionStatus.ABORTED > at org .jboss.jca.core.connectionmanager.tx.TxConnectionManagerImpl.getManagedConnection(TxConnectionManagerImpl.java:408) ...省略了45个常用框架TxConnectionManagerImpl.getManagedConnection(TxConnectionManagerImpl.java:424) 在 org.jboss.jca.core.connectionmanager.AbstractConnectionManager.allocateConnection(AbstractConnectionManager.java:747) 在 org.jboss.jca.adapters.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java: 138)...省略了 43 个公共帧 原因:javax.resource.ResourceException:IJ000459:事务未激活:tx=TransactionImple < ac,BasicAction:0:ffffc0a83842:6e69d97c:5a16d4f3:18 状态:ActionStatus.ABORTED > at org .jboss.jca.core.connectionmanager.tx.TxConnectionManagerImpl.getManagedConnection(TxConnectionManagerImpl.java:408) ...省略了45个常用框架java:747) at org.jboss.jca.adapters.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:138) ... 省略了 43 个常见帧 原因:javax.resource.ResourceException:IJ000459:事务未激活:tx= TransactionImple < ac, BasicAction: 0:ffffc0a83842:6e69d97c:5a16d4f3:18 status: ActionStatus.ABORTED > at org.jboss.jca.core.connectionmanager.tx.TxConnectionManagerImpl.getManagedConnection(TxConnectionManagerImpl.java:408) ... 45 个常用帧省略java:747) at org.jboss.jca.adapters.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:138) ... 省略了 43 个常见帧 原因:javax.resource.ResourceException:IJ000459:事务未激活:tx= TransactionImple < ac, BasicAction: 0:ffffc0a83842:6e69d97c:5a16d4f3:18 status: ActionStatus.ABORTED > at org.jboss.jca.core.connectionmanager.tx.TxConnectionManagerImpl.getManagedConnection(TxConnectionManagerImpl.java:408) ... 45 个常用帧省略connectionmanager.tx.TxConnectionManagerImpl.getManagedConnection(TxConnectionManagerImpl.java:408) ...省略了45个常用帧connectionmanager.tx.TxConnectionManagerImpl.getManagedConnection(TxConnectionManagerImpl.java:408) ...省略了45个常用帧
编辑:添加了 persistence.xml
<persistence-unit transaction-type="JTA" name="dadsadsadsa">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<jta-data-source>java:jboss/datasources/dadsadsadsaas</jta-data-source>
<properties>
<property name="hibernate.show_sql" value="false"/>
<property name="hibernate.id.new_generator_mappings" value="false"/>
<property name="db.migration.action" value="validate-migrate"/>
<property name="db.migration.sql.prefix" value="adadsadsadsa-"/>
</properties>
</persistence-unit>