I'm pretty sure it's a bug in DBCP2 but the issue was complicated and I
didn't have time to do any more than fix it at the time. Maybe it doesn't
affect all dbs though because I'm surprised no one else has raised the
issue. I can't say what affect it might have on other database servers.
On 9 March 2016 at 03:35, Jacques Le Roux <jacques.le.r...@les7arts.com>
wrote:
Hi Scott,
I think it's a good question from Vyom. Is that only specific to MySQL? A
specific MySQL version?
Thanks
Jacques
Le 29/02/2016 13:31, Vyom Jain a écrit :
Thanks, shouldn't this be committed in SVN then?
--
Vyom
On 29 February 2016 at 14:51, Scott Gray <scott.g...@hotwaxsystems.com>
wrote:
Actually yes, I have encountered this. I fixed it with the following
class, which you would then use in the DBCPConnectionFactory class in
place
of the PoolableManagedConnectionFactory.
/**
* An extension to the DBCP2 PoolableManagedConnectionFactory that
ensures
that
* PoolableConnections are always set to setCacheState(false). This
is
needed
* because otherwise PoolableConnections will cache the autoCommit
setting
of the
* underlying connection even though the flag on the underlying
connection
is often set
* directly (specifically by LocalXAConnectionFactory.LocalXAResource,
see
start()
* and commit()).
*/
public class DBCPPoolableManagedConnectionFactory extends
PoolableManagedConnectionFactory {
@Override
public synchronized PooledObject<PoolableConnection> makeObject()
throws
Exception {
PooledObject<PoolableConnection> pooledObject =
super.makeObject();
pooledObject.getObject().setCacheState(false);
return pooledObject;
}
public DBCPPoolableManagedConnectionFactory(XAConnectionFactory
connFactory, ObjectName dataSourceJmxName) {
super(connFactory, dataSourceJmxName);
}
}
Regards
Scott
On 26 February 2016 at 19:48, Vyom Jain <vyom0...@gmail.com> wrote:
Hello Everyone,
I've been observing frequent errors such as
"org.ofbiz.entity.GenericDataSourceException: Unable to esablish a
connection with the database. (Unable to acquire a new connection from
the
pool)". While OFBiz restart helps for sometime, but we would like to
avoid
frequent restarts.
I'm wondering if someone else has faced same issues or would like to
share
their thoughts. Could it be that upgrade to DBCP2 has introduced new
bugs?
I'm using OFBiz trunk (revision 1704086) + MySQL v5.6 + MySQL JDBC
driver
v5.1.38 + JDK 7. This version uses Apache DBCP2.
entityengine.xml configuration -
- pool-minsize = "2"
- pool-maxsize = "250"
- time-between-eviction-runs-millis="600000" [used to give same errors
with
-1]
Below is the stacktrace of associated with one of these errors -
org.ofbiz.entity.GenericDataSourceException: Unable to esablish a
connection with the database. (Unable to acquire a new connection from
the
pool). Rolling back transaction.
org.ofbiz.entity.GenericDataSourceException: Unable to esablish a
connection with the database. (Unable to acquire a new connection from
the
pool)
at
org.ofbiz.entity.jdbc.SQLProcessor.getConnection(SQLProcessor.java:263)
~[ofbiz-entity.jar:?]
at
org.ofbiz.entity.jdbc.SQLProcessor.prepareStatement(SQLProcessor.java:366)
~[ofbiz-entity.jar:?]
at
org.ofbiz.entity.jdbc.SQLProcessor.prepareStatement(SQLProcessor.java:350)
~[ofbiz-entity.jar:?]
at
org.ofbiz.entity.datasource.GenericDAO.select(GenericDAO.java:521)
~[ofbiz-entity.jar:?]
at
org.ofbiz.entity.datasource.GenericDAO.select(GenericDAO.java:492)
~[ofbiz-entity.jar:?]
at
org.ofbiz.entity.datasource.GenericHelperDAO.findByPrimaryKey(GenericHelperDAO.java:80)
~[ofbiz-entity.jar:?]
at
org.ofbiz.entity.GenericDelegator.findOne(GenericDelegator.java:1580)
[ofbiz-entity.jar:?]
at com.mycompany.CustomEvents.addToCart(CustomEvents.java:544)
[ofbiz-mycompanyerp.jar:?]
at sun.reflect.GeneratedMethodAccessor202.invoke(Unknown Source)
~[?:?]
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
~[?:1.7.0_79]
at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_79]
at
org.ofbiz.webapp.event.JavaEventHandler.invoke(JavaEventHandler.java:92)
[ofbiz-webapp.jar:?]
at
org.ofbiz.webapp.event.JavaEventHandler.invoke(JavaEventHandler.java:78)
[ofbiz-webapp.jar:?]
at
org.ofbiz.webapp.control.RequestHandler.runEvent(RequestHandler.java:759)
[ofbiz-webapp.jar:?]
at
org.ofbiz.webapp.control.RequestHandler.doRequest(RequestHandler.java:476)
[ofbiz-webapp.jar:?]
at
org.ofbiz.webapp.control.ControlServlet.doGet(ControlServlet.java:213)
[ofbiz-webapp.jar:?]
at
org.ofbiz.webapp.control.ControlServlet.doPost(ControlServlet.java:88)
[ofbiz-webapp.jar:?]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
[servlet-api-3.0.jar:?]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
[servlet-api-3.0.jar:?]
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
[tomcat-7.0.64-catalina.jar:7.0.64]
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
[tomcat-7.0.64-catalina.jar:7.0.64]
at
org.ofbiz.webapp.control.ContextFilter.doFilter(ContextFilter.java:324)
[ofbiz-webapp.jar:?]
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
[tomcat-7.0.64-catalina.jar:7.0.64]
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
[tomcat-7.0.64-catalina.jar:7.0.64]
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
[tomcat-7.0.64-catalina.jar:7.0.64]
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
[tomcat-7.0.64-catalina.jar:7.0.64]
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
[tomcat-7.0.64-catalina.jar:7.0.64]
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
[tomcat-7.0.64-catalina.jar:7.0.64]
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
[tomcat-7.0.64-catalina.jar:7.0.64]
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
[tomcat-7.0.64-catalina.jar:7.0.64]
at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
[tomcat-7.0.64-catalina.jar:7.0.64]
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
[tomcat-7.0.64-catalina.jar:7.0.64]
at
org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:190)
[tomcat-7.0.64-tomcat-coyote.jar:7.0.64]
at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
[tomcat-7.0.64-tomcat-coyote.jar:7.0.64]
at
org.apache.tomcat.util.net
.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
[tomcat-7.0.64-tomcat-coyote.jar:7.0.64]
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
[?:1.7.0_79]
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
[?:1.7.0_79]
at
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
[tomcat-7.0.64-tomcat-coyote.jar:7.0.64]
at java.lang.Thread.run(Thread.java:745) [?:1.7.0_79]
Caused by: java.sql.SQLException: Unable to acquire a new connection
from
the pool
at
org.apache.commons.dbcp2.managed.ManagedConnection.updateTransactionStatus(ManagedConnection.java:130)
~[commons-dbcp2-2.1.jar:2.1]
at
org.apache.commons.dbcp2.managed.ManagedConnection.<init>(ManagedConnection.java:60)
~[commons-dbcp2-2.1.jar:2.1]
at
org.apache.commons.dbcp2.managed.ManagedDataSource.getConnection(ManagedDataSource.java:82)
~[commons-dbcp2-2.1.jar:2.1]
at
org.ofbiz.entity.connection.DebugManagedDataSource.getConnection(DebugManagedDataSource.java:52)
~[ofbiz-entity.jar:?]
at
org.ofbiz.entity.connection.DBCPConnectionFactory.getConnection(DBCPConnectionFactory.java:63)
~[ofbiz-entity.jar:?]
at
org.ofbiz.geronimo.GeronimoTransactionFactory.getConnection(GeronimoTransactionFactory.java:83)
~[ofbiz-geronimo.jar:?]
at
org.ofbiz.entity.jdbc.SQLProcessor.getConnection(SQLProcessor.java:260)
~[ofbiz-entity.jar:?]
... 38 more
Caused by: java.util.NoSuchElementException: Timeout waiting for idle
object
at
org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:449)
~[commons-pool2-2.3.jar:2.3]
at
org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:363)
~[commons-pool2-2.3.jar:2.3]
at
org.apache.commons.dbcp2.managed.ManagedConnection.updateTransactionStatus(ManagedConnection.java:127)
~[commons-dbcp2-2.1.jar:2.1]
at
org.apache.commons.dbcp2.managed.ManagedConnection.<init>(ManagedConnection.java:60)
~[commons-dbcp2-2.1.jar:2.1]
at
org.apache.commons.dbcp2.managed.ManagedDataSource.getConnection(ManagedDataSource.java:82)
~[commons-dbcp2-2.1.jar:2.1]
at
org.ofbiz.entity.connection.DebugManagedDataSource.getConnection(DebugManagedDataSource.java:52)
~[ofbiz-entity.jar:?]
at
org.ofbiz.entity.connection.DBCPConnectionFactory.getConnection(DBCPConnectionFactory.java:63)
~[ofbiz-entity.jar:?]
at
org.ofbiz.geronimo.GeronimoTransactionFactory.getConnection(GeronimoTransactionFactory.java:83)
~[ofbiz-geronimo.jar:?]
at
org.ofbiz.entity.jdbc.SQLProcessor.getConnection(SQLProcessor.java:260)
~[ofbiz-entity.jar:?]
... 38 more
--
Vyom