Spring - Hibernate - JBOSS - No ManagedConnections available within configured blocking timeout ( 30000 [ms] )

纵然是瞬间 提交于 2019-12-24 11:36:49

问题


I am using Spring 3.0.1 and Hibernate 3.2 with JBOSS 4.2.2 and we are using Spring transaction management to manage the transactions.

My code implementation runs a huge job that runs for nearly 10 minutes.The spring service bean RunJobBean.java is the entry point for my job and this instantiates a number of independent threads (each performing different DB updates and other logic etc) and these threads invokes the hibernate DAO beans (These are injected into RunJobBean which passes on to threads) to read from DB2 server and reads and writes data into two different Oracle databases (running on two different servers).

The bean StartRunJob.java does the necessary pre-processing and invokes RunJobBean to run the job.

This use to work fine until the recent change.

The bean StartRunJob.java (managed by another team. I have no control over this) has been modified recently to invoke multiple jobs in parallel. So StartRunJob invokes multiple independent threads and each of these threads invokes my RunJobBean. On running the StartRunJob, I am getting the below mentioned errors. The log shows this is from my code.

org.hibernate.exception.GenericJDBCException: Cannot open connection Caused by: org.jboss.util.NestedSQLException: No ManagedConnections available within configured blocking timeout ( 30000 [ms] ); - nested throwable: (javax.resource.ResourceException: No ManagedConnections available within configured blocking timeout ( 30000 [ms] ))

The max number of connections configured on the server is 5 and min is 1. Everyone is under the impression that my code connecting to Oracle DB1 is eating off all the connections and not releasing them. THe JBOSS console shows InUseConnectionCount as 3 or 4 or 5. But still I am seeing this issue. But My code connecting to second OracleDB also has max connections as 5 but I am invoking 12 different threads to made DB calls and this works fine.

I want an advice on how I can getrid of this issue.

Thanks in advance.

Some questions related to this. 1. How can I check in JBOSS which bean is holding a db connection? 2. How can I check in JBOSS how many DB connections are idle?


回答1:


I have solved this problem. Have identified a leak in the transaction.

Update: it has been long back I worked on this, But as I remember, In one of the transactions, a property has to be readonly where as it was assigned something similar to update, because of this multiple number of calls were fired by spring to DB. When we changed it to readonly, things were to normal.

But I still keep this question open for some expert to answer other questions so they will be helpful to someone.



来源:https://stackoverflow.com/questions/22053681/spring-hibernate-jboss-no-managedconnections-available-within-configured-b

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!