Java jboss wildfly 数据源连接失败 - 在配置的阻塞超时内没有可用的托管连接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28212746/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
jboss wildfly datasource connection failing - No managed connections available within configured blocking timeout
提问by simonC
I have a jboss wildfly server connected to a mysql database via a datasource configured on the app server.
我有一个 jboss wildfly 服务器通过应用服务器上配置的数据源连接到 mysql 数据库。
It hapens some time that the mysql database is not accessible for an amount of time (netework problem etc...), when the mysql is not accessible I receive in logs the message :
有时 mysql 数据库在一段时间内无法访问(网络问题等...),当无法访问 mysql 时,我在日志中收到消息:
09:42:30,015 ERROR [org.jboss.seam.async.AsynchronousExceptionHandler] (4pm_services_QuartzScheduler_Worker-4) Exception thrown whilst executing asynchronous call: java.
lang.RuntimeException: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Cannot open connection
this is expected as thy mysql is not available at that moment, the porblem is that when the mysql server comes online again the error still persists, and the jboss server is unable to get a valid from the connection pool.
这是预料之中的,因为此时你的 mysql 不可用,问题是当 mysql 服务器再次上线时,错误仍然存在,并且 jboss 服务器无法从连接池中获取有效信息。
I have: wildfly 8.1 mysql 5.5 use JPA for comunicating with database
我有:wildfly 8.1 mysql 5.5 使用 JPA 与数据库通信
here is the datasource configuration:
这是数据源配置:
<datasource jta="true" jndi-name="java:jboss/services_DS" pool-name="fourPmDSServices" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://192.168.10.110:3306/FOUR_PM__SERVICES?useUnicode=true&characterEncoding=UTF-8</connection-url>
<driver>mysql</driver>
<new-connection-sql>select 1</new-connection-sql>
<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
<pool>
<min-pool-size>1</min-pool-size>
<max-pool-size>5</max-pool-size>
<prefill>true</prefill>
<use-strict-min>false</use-strict-min>
</pool>
<security>
<user-name>*********</user-name>
<password>*********</password>
</security>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker"/>
<check-valid-connection-sql>select 1</check-valid-connection-sql>
<stale-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLStaleConnectionChecker"/>
<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter"/>
</validation>
<statement>
<prepared-statement-cache-size>10</prepared-statement-cache-size>
<share-prepared-statements>true</share-prepared-statements>
</statement>
</datasource>
And here is the complete stack trace of the error:
这是错误的完整堆栈跟踪:
00:00:00,017 WARN [org.hibernate.util.JDBCExceptionReporter] (4pm_services_QuartzScheduler_Worker-2) SQL Error: 0, SQLState: null
00:00:00,018 ERROR [org.hibernate.util.JDBCExceptionReporter] (4pm_services_QuartzScheduler_Worker-2) javax.resource.ResourceException: IJ000453: Unable to get managed connection for java:jboss/services_DS
00:00:00,018 ERROR [org.jboss.seam.async.AsynchronousExceptionHandler] (4pm_services_QuartzScheduler_Worker-2) Exception thrown whilst executing asynchronous call: java.lang.RuntimeException: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Cannot open connection
at si.arctur.fourPmServices.scheduleJobs.QuartzJobBase.executeInternal(QuartzJobBase.java:91) [4pm_services-ejb.jar:]
at si.arctur.fourPmServices.scheduleJobs.QuartzJobBase.schedule(QuartzJobBase.java:76) [4pm_services-ejb.jar:]
at sun.reflect.GeneratedMethodAccessor98.invoke(Unknown Source) [:1.6.0_32]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.6.0_32]
at java.lang.reflect.Method.invoke(Method.java:622) [rt.jar:1.6.0_32]
at org.jboss.seam.util.Reflections.invoke(Reflections.java:22) [jboss-seam.jar:2.2.2.Final]
at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32) [jboss-seam.jar:2.2.2.Final]
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56) [jboss-seam.jar:2.2.2.Final]
at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28) [jboss-seam.jar:2.2.2.Final]
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) [jboss-seam.jar:2.2.2.Final]
at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:77) [jboss-seam.jar:2.2.2.Final]
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) [jboss-seam.jar:2.2.2.Final]
at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44) [jboss-seam.jar:2.2.2.Final]
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) [jboss-seam.jar:2.2.2.Final]
at org.jboss.seam.async.AsynchronousInterceptor.aroundInvoke(AsynchronousInterceptor.java:52) [jboss-seam.jar:2.2.2.Final]
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) [jboss-seam.jar:2.2.2.Final]
at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107) [jboss-seam.jar:2.2.2.Final]
at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185) [jboss-seam.jar:2.2.2.Final]
at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103) [jboss-seam.jar:2.2.2.Final]
at si.arctur.fourPmServices.scheduleJobs.emailSender.MailChecker_$$_javassist_seam_2.schedule(MailChecker_$$_javassist_seam_2.java) [4pm_services-ejb.jar:]
at sun.reflect.GeneratedMethodAccessor104.invoke(Unknown Source) [:1.6.0_32]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.6.0_32]
at java.lang.reflect.Method.invoke(Method.java:622) [rt.jar:1.6.0_32]
at org.jboss.seam.util.Reflections.invoke(Reflections.java:22) [jboss-seam.jar:2.2.2.Final]
at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144) [jboss-seam.jar:2.2.2.Final]
at org.jboss.seam.async.AsynchronousInvocation.process(AsynchronousInvocation.java:62) [jboss-seam.jar:2.2.2.Final]
at org.jboss.seam.async.Asynchronous$ContextualAsynchronousRequest.run(Asynchronous.java:80) [jboss-seam.jar:2.2.2.Final]
at org.jboss.seam.async.AsynchronousInvocation.execute(AsynchronousInvocation.java:44) [jboss-seam.jar:2.2.2.Final]
at org.jboss.seam.async.QuartzDispatcher$QuartzJob.execute(QuartzDispatcher.java:243) [jboss-seam.jar:2.2.2.Final]
at org.quartz.core.JobRunShell.run(JobRunShell.java:202) [quartz.jar:1.6.0]
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:529) [quartz.jar:1.6.0]
Caused by: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Cannot open connection
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1389) [hibernate-core.jar:3.6.10.Final]
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1317) [hibernate-core.jar:3.6.10.Final]
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:255) [hibernate-core.jar:3.6.10.Final]
at si.arctur.fourPmServices.scheduleJobs.emailSender.MailChecker.checkQueue(MailChecker.java:37) [4pm_services-ejb.jar:]
at si.arctur.fourPmServices.scheduleJobs.emailSender.MailChecker.execute(MailChecker.java:26) [4pm_services-ejb.jar:]
at si.arctur.fourPmServices.scheduleJobs.QuartzJobBase$TransactionalWork.work(QuartzJobBase.java:144) [4pm_services-ejb.jar:]
at org.jboss.seam.util.Work.workInTransaction(Work.java:61) [jboss-seam.jar:2.2.2.Final]
at si.arctur.fourPmServices.scheduleJobs.QuartzJobBase.executeInternal(QuartzJobBase.java:89) [4pm_services-ejb.jar:]
... 30 more
Caused by: org.hibernate.exception.GenericJDBCException: Cannot open connection
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:140) [hibernate-core.jar:3.6.10.Final]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:128) [hibernate-core.jar:3.6.10.Final]
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) [hibernate-core.jar:3.6.10.Final]
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:52) [hibernate-core.jar:3.6.10.Final]
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:449) [hibernate-core.jar:3.6.10.Final]
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167) [hibernate-core.jar:3.6.10.Final]
at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:161) [hibernate-core.jar:3.6.10.Final]
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1700) [hibernate-core.jar:3.6.10.Final]
at org.hibernate.loader.Loader.doQuery(Loader.java:801) [hibernate-core.jar:3.6.10.Final]
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274) [hibernate-core.jar:3.6.10.Final]
at org.hibernate.loader.Loader.doList(Loader.java:2542) [hibernate-core.jar:3.6.10.Final]
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276) [hibernate-core.jar:3.6.10.Final]
at org.hibernate.loader.Loader.list(Loader.java:2271) [hibernate-core.jar:3.6.10.Final]
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:459) [hibernate-core.jar:3.6.10.Final]
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:365) [hibernate-core.jar:3.6.10.Final]
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196) [hibernate-core.jar:3.6.10.Final]
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1268) [hibernate-core.jar:3.6.10.Final]
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102) [hibernate-core.jar:3.6.10.Final]
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:246) [hibernate-core.jar:3.6.10.Final]
... 35 more
Caused by: java.sql.SQLException: javax.resource.ResourceException: IJ000453: Unable to get managed connection for java:jboss/services_DS
at org.jboss.jca.adapters.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:137)
at org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.getConnection(InjectedDataSourceConnectionProvider.java:71) [hibernate-core.jar:3.6.10.Final]
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446) [hibernate-core.jar:3.6.10.Final]
... 49 more
Caused by: javax.resource.ResourceException: IJ000453: Unable to get managed connection for java:jboss/services_DS
at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.getManagedConnection(AbstractConnectionManager.java:390)
at org.jboss.jca.core.connectionmanager.tx.TxConnectionManagerImpl.getManagedConnection(TxConnectionManagerImpl.java:368)
at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.allocateConnection(AbstractConnectionManager.java:464)
at org.jboss.jca.adapters.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:129)
... 51 more
Caused by: javax.resource.ResourceException: IJ000655: No managed connections available within configured blocking timeout (30000 [ms])
at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreArrayListManagedConnectionPool.getConnection(SemaphoreArrayListManagedConnectionPool.java:377)
at org.jboss.jca.core.connectionmanager.pool.AbstractPool.getTransactionNewConnection(AbstractPool.java:495)
at org.jboss.jca.core.connectionmanager.pool.AbstractPool.getConnection(AbstractPool.java:374)
at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.getManagedConnection(AbstractConnectionManager.java:329)
... 54 more
回答by cilap
It looks like you need to define a flush strategy of you failed connections. check the "flush-strategy" param.
看起来您需要定义失败连接的刷新策略。检查“刷新策略”参数。
A good point to start is here: https://docs.jboss.org/author/display/WFLY8/DataSource+configuration
一个很好的起点是:https: //docs.jboss.org/author/display/WFLY8/DataSource+configuration
They reference this XSD: http://www.ironjacamar.org/doc/schema/datasources_1_1.xsd
他们引用了这个 XSD:http: //www.ironjacamar.org/doc/schema/datasources_1_1.xsd
And the XSD decription is here: http://www.ironjacamar.org/doc/userguide/1.2/en-US/html_single/index.html#deployingds
XSD 描述在这里:http: //www.ironjacamar.org/doc/userguide/1.2/en-US/html_single/index.html#deployingds
In your case I would try to figure out the network issues. Independently of this. I would in your case (with bad connection issues) flush my complete connection pool: flush-strategy => EntirePool
在您的情况下,我会尝试找出网络问题。独立于此。我会在你的情况下(有错误的连接问题)刷新我的完整连接池:flush-strategy => EntirePool
good luck on fixing such an odd issue
祝你好运解决这样一个奇怪的问题
回答by Naman P
Caused by: javax.resource.ResourceException: IJ000655: No managed connections available within configured blocking timeout (30000 [ms])
引起:javax.resource.ResourceException:IJ000655:在配置的阻塞超时(30000 [ms])内没有可用的托管连接
This message says, that configured pool cannot provide any connection within configured timeout of 3sec (3000msec). Either your pool is too low or your connections are not closed after usage, perhaps increasing the pool size will work.
此消息表示,配置的池无法在配置的 3 秒(3000 毫秒)超时内提供任何连接。要么你的池太低,要么你的连接在使用后没有关闭,也许增加池大小会起作用。
Also check the connection close from JBoss.
还要检查从 JBoss 关闭的连接。
回答by Ranjitsinh
Caused by: javax.resource.ResourceException: IJ000453: Unable to get managed connection for java:jboss/services_DS
引起:javax.resource.ResourceException: IJ000453: Unable to get managed connection for java:jboss/services_DS
It seem that problem is related to some database table and java configuration like hbm.xml. For each Table Type parameter the java api opens a connection to database or due to some other environment configuration.
似乎问题与一些数据库表和java配置有关,如hbm.xml。对于每个表类型参数,java api 打开到数据库的连接或由于其他一些环境配置。
Please refer following link here you will get same problem with solution.
请在此处参考以下链接,您将遇到与解决方案相同的问题。
https://developer.jboss.org/thread/211940
https://developer.jboss.org/thread/211940
http://www.coderanch.com/t/556721/JBoss/Jboss-Datasource-configured-correctly-unable
http://www.coderanch.com/t/556721/JBoss/Jboss-Datasource-configured-correctly-unable
回答by Harsh
What Does The Message No Managed Connection Available mean?
没有可用的托管连接消息是什么意思?
It means that all possible connections to the db are in use and/or that a thread has timed-out waiting for a connection to open up.
这意味着与数据库的所有可能连接都在使用中和/或线程已超时等待连接打开。
Possible solutions:
可能的解决方案:
Increase your connection pool size
增加连接池大小
Add
添加
<max-pool-size>whatever</max-pool-size>
<max-pool-size>whatever</max-pool-size>
to your -ds.xml file to increase
给你的 -ds.xml 文件增加
the number of connections available. The default is 20
可用的连接数。默认值为 20
There is an attribute
有一个属性
MaxConnectionsInUse
使用中的最大连接数
viewable on the jmx-console against the
可在 jmx 控制台上查看
ManagedConnectionPool
托管连接池
that can help you understand how many connections you really need.
这可以帮助您了解您真正需要多少连接。
Tell your threads to wait longer for a connection to open up
告诉您的线程等待更长时间以打开连接
Add
添加
<blocking-timeout-millis>whatever</blocking-timeout-millis>
<blocking-timeout-millis>whatever</blocking-timeout-millis>
to your -ds.xml file to increase the length of time to wait. The default is 30000 (5000 before JBoss-3.2.4) milli-seconds.
到您的 -ds.xml 文件以增加等待的时间长度。默认值为 30000(JBoss-3.2.4 之前的 5000)毫秒。
Make sure you are properly closing open connections
确保您正确关闭打开的连接
回答by srinivasa dutt pulipaka
debug="true" error="true" in the JCA in standalone-ha.xml
Standalone-ha.xml 中 JCA 中的 debug="true" error="true"
Verify that exists in the jca subsystem and set debug="true". ... ... Then in server.log it will write if any connections are not closing with stack trace of the code.
验证存在于 jca 子系统中并设置 debug="true"。... ... 然后在 server.log 中,如果任何连接没有关闭,它就会写入代码的堆栈跟踪。
回答by Rafael Capretz
I had a similar issue that I fixed with the answer that @Harsh said. I increased the maxpoolsize from 20 to 100 and the problem is gone.
我有一个类似的问题,我用@Harsh 说的答案解决了这个问题。我将 maxpoolsize 从 20 增加到 100,问题就解决了。
回答by Robert Hines
I encountered this issue as well. However, my connection worked briefly and then stopped working after a number of requests. It turned out to be an unclosed connection to the database, which caused connections to be consumed and eventually exhausting the connection pool. Simply increasing the connection pool size will only delay the eventual error. You'll need to identify where you not correctly closing your connection in order to resolve this issue.
我也遇到了这个问题。但是,我的连接短暂工作,然后在多次请求后停止工作。原来是一个未关闭的数据库连接,导致连接被消耗,最终耗尽连接池。简单地增加连接池大小只会延迟最终的错误。您需要确定未正确关闭连接的位置以解决此问题。