gpt4 book ai didi

hibernate - 连接未与托管连接关联。org.jboss.resource.adapter.jdbc.jdk6.WrappedConnectionJDK6

转载 作者:行者123 更新时间:2023-12-03 04:25:15 24 4
gpt4 key购买 nike

我在 JBoss 服务器上使用 Hibernate。我收到以下错误。

当我尝试在同一 session 中第二次连接到数据库时,会发生错误。

我还收到错误“正在为您关闭连接。请关闭您的连接”。

    14:28:37,869 ERROR [HibernateUtil] HibernateException  occurred in executeQuery  method   in  HibernateUtil class 
org.hibernate.exception.GenericJDBCException: could not execute query
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:126)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:114)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.doList(Loader.java:2231)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
at org.hibernate.loader.Loader.list(Loader.java:2120)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:361)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1148)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
at com.a.amc.dao.utils.HibernateUtil.executeQuery(HibernateUtil.java:154)
at com.a.amc.service.impl.CityServiceImpl.isCityExists(CityServiceImpl.java:142)
at com.a.amc.service.impl.CityServiceImpl.addCity(CityServiceImpl.java:38)
at com.a.amc.web.actions.CityAction.addCity(CityAction.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)

14:28:37,869 ERROR [JDBCTransaction] Could not toggle autocommit
java.sql.SQLException: Connection is not associated with a managed connection.org.jboss.resource.adapter.jdbc.jdk6.WrappedConnectionJDK6@1269ca1
at org.jboss.resource.adapter.jdbc.WrappedConnection.lock(WrappedConnection.java:81)
at org.jboss.resource.adapter.jdbc.WrappedConnection.setAutoCommit(WrappedConnection.java:454)
at org.hibernate.transaction.JDBCTransaction.toggleAutoCommit(JDBCTransaction.java:228)
at org.hibernate.transaction.JDBCTransaction.rollbackAndResetAutoCommit(JDBCTransaction.java:220)
at org.hibernate.transaction.JDBCTransaction.rollback(JDBCTransaction.java:196)
at com.a.amc.dao.utils.HibernateUtil.executeQuery(HibernateUtil.java:159)
at com.a.amc.service.impl.CityServiceImpl.isCityExists(CityServiceImpl.java:142)
at com.a.amc.service.impl.CityServiceImpl.addCity(CityServiceImpl.java:38)
at com.a.amc.web.actions.CityAction.addCity(CityAction.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)

14:28:37,869 ERROR [JDBCTransaction] JDBC rollback failed
java.sql.SQLException: Connection is not associated with a managed connection.org.jboss.resource.adapter.jdbc.jdk6.WrappedConnectionJDK6@1269ca1
at org.jboss.resource.adapter.jdbc.WrappedConnection.lock(WrappedConnection.java:81)
at org.jboss.resource.adapter.jdbc.WrappedConnection.rollback(WrappedConnection.java:496)
at org.hibernate.transaction.JDBCTransaction.rollbackAndResetAutoCommit(JDBCTransaction.java:217)
at org.hibernate.transaction.JDBCTransaction.rollback(JDBCTransaction.java:196)
at com.a.amc.dao.utils.HibernateUtil.executeQuery(HibernateUtil.java:159)
at com.a.amc.service.impl.CityServiceImpl.isCityExists(CityServiceImpl.java:142)
at com.a.amc.service.impl.CityServiceImpl.addCity(CityServiceImpl.java:38)
at com.a.amc.web.actions.CityAction.addCity(CityAction.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)

14:28:37,869 ERROR [CityServiceImpl] Exception occurred in isCityExists method in CityServiceImpl
org.hibernate.TransactionException: JDBC rollback failed
at org.hibernate.transaction.JDBCTransaction.rollback(JDBCTransaction.java:204)
at com.a.amc.dao.utils.HibernateUtil.executeQuery(HibernateUtil.java:159)
at com.a.amc.service.impl.CityServiceImpl.isCityExists(CityServiceImpl.java:142)
at com.a.amc.service.impl.CityServiceImpl.addCity(CityServiceImpl.java:38)
at com.a.amc.web.actions.CityAction.addCity(CityAction.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)

可能是什么原因,如何解决这种情况?

最佳答案

自从您一年前问这个问题以来,这个答案实际上可能已经太晚了。但这会对那些将来遇到此错误的人有所帮助。

您的错误可能来自不同的来源,但在我的情况下,这完全与事务超时有关,某些查询可能需要很长时间,因此达到超时并且 hibernate 会引发异常。就我而言,我所做的是将事务超时设置为更高的值。这解决了我的问题。

这是一个有用的链接。 The transaction is not active!

Understanding JDBC internal timeouts config

-干杯

关于hibernate - 连接未与托管连接关联。org.jboss.resource.adapter.jdbc.jdk6.WrappedConnectionJDK6,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8412828/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com