JIRA throws exception java.lang.ClassNotFoundException for DB driver
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Problem
JIRA runs out of available DB connections. The following appears in the atlassian-jira.log:
2016-05-10 02:36:41,795 http-bio-80-exec-17 ERROR admin 156x1827812x2 1wdfh3b 1.1.1.1 /secure/RapidBoard.jspa [NoModule] There was an error getting a DBCP datasource.
java.lang.RuntimeException: Unable to obtain a connection from the underlying connection pool
at org.ofbiz.core.entity.jdbc.interceptors.connection.ConnectionTracker.trackConnection(ConnectionTracker.java:59)
at org.ofbiz.core.entity.transaction.DBCPConnectionFactory.trackConnection(DBCPConnectionFactory.java:243)
at org.ofbiz.core.entity.transaction.DBCPConnectionFactory.getConnection(DBCPConnectionFactory.java:74)
at org.ofbiz.core.entity.ConnectionFactory.tryGenericConnectionSources(ConnectionFactory.java:69)
....
Caused by: java.util.NoSuchElementException: Timeout waiting for idle object
at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:1134)
at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:106)
... 305 more
And after that there could be another stacktrace:
2016-05-10 02:36:41,938 http-bio-80-exec-11 WARN admin 156x1827822x5 1hfai41 1.1.1.1 /rest/issueNav/1/issueTable/stable [NoModule]
java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver
at com.atlassian.plugins.rest.module.ChainingClassLoader.loadClass(ChainingClassLoader.java:65)
at org.ofbiz.core.entity.ConnectionFactory.tryGenericConnectionSources(ConnectionFactory.java:81)
at org.ofbiz.core.entity.transaction.JNDIFactory.getConnection(JNDIFactory.java:146)
at org.ofbiz.core.entity.TransactionFactory.getConnection(TransactionFactory.java:136)
Another example:
2019-12-23 10:22:53,100 http-nio-8080-exec-65 url:/rest/analytics/1.0/publish/bulk WARN - [NoModule] Could not find JDBC driver class named com.mysql.jdbc.Driver.
2019-12-23 10:22:53,100 http-nio-8080-exec-65 url:/rest/analytics/1.0/publish/bulk WARN - [NoModule]
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver not found from bundle [com.atlassian.whisper.atlassian-whisper-plugin]
at org.eclipse.gemini.blueprint.util.BundleDelegatingClassLoader.findClass(BundleDelegatingClassLoader.java:139)
at org.eclipse.gemini.blueprint.util.BundleDelegatingClassLoader.loadClass(BundleDelegatingClassLoader.java:211)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.ofbiz.core.entity.ConnectionFactory.tryGenericConnectionSources(ConnectionFactory.java:81)
at org.ofbiz.core.entity.transaction.JNDIFactory.getConnection(JNDIFactory.java:173)
at org.ofbiz.core.entity.TransactionFactory.getConnection(TransactionFactory.java:114)
at org.ofbiz.core.entity.ConnectionFactory.getConnection(ConnectionFactory.java:59)
at com.atlassian.jira.ofbiz.DefaultOfBizConnectionFactory.getConnection(DefaultOfBizConnectionFactory.java:44)
...
Note, this could be any other DB class: eg. com.mysql.jdbc.Driver
Cause
Please note they both executing tryGenericConnectionSources method, but at different stages:
at org.ofbiz.core.entity.ConnectionFactory.tryGenericConnectionSources(ConnectionFactory.java:69)
vs
at org.ofbiz.core.entity.ConnectionFactory.tryGenericConnectionSources(ConnectionFactory.java:81)
First tries to get a connection from the pool and if that fails, it creates its own connection. That second part is not supposed to work, as OfBiz doesn't have required configuration data and moreover it doesn't have required classloader context.
Resolution
Please ignore the last ClassNotFoundException this is Red herring.