When using jdbc connection pools, reconnects end up using a classloader
that doesn’t use any of the existing classloaders that have the driver
jar
so they fail.
The only way I have gotten it to work is to set the classpath using a
wildcard entry or explicit entry for the jarfile. Just having the jars
in
the start path or lib doesn’t work.
So is having OS/shell specific start scripts that set the classpath
before
loading jruby the only way to handle this? That appears to be the case
but
thought I would ask before converting my gem binaries.
hi, would you tell me a little more what you are doing like: what are
all
those existing classloaders that have the driver jar ? are you using
JDBC
directly from jruby ?
are you talking about $CLASSPATH variable inside JRuby which is
something
different than $CLASSPATH from environment ?!
are you using jruby-complete.jar or rvm/rbenv/chruby installed jruby ?
I’m using rvm but not tied to it, does it mess with jruby’s ability to
set
the classpath correctly?
By classpath I mean classpath as displayed in
System.getProperty('java.class.path").
All of the jdbc connection pools are setup in java code. I use them
from a
mix of ruby/java but the errors always come from the java side
connection
pool reconnect logic where they try to get a new connection after idle
timeouts have killed current connections, or where it’s expanding the
pool,
etc…
Here is the stack trace I get. You can see the pool timing out idle
connections, and then failing to get a new connection because it can’t
load
the driver.
20:49:24.962 [Hikari Housekeeping Timer (pool HikariPool-0)] DEBUG
com.zaxxer.hikari.pool.HikariPool - Before cleanup pool stats
HikariPool-0
(total=10, inUse=0, avail=10, waiting=0)¬
197284 20:49:24.972 [Hikari Housekeeping Timer (pool HikariPool-0)]
DEBUG
com.zaxxer.hikari.pool.HikariPool - After cleanup pool stats
HikariPool-0
(total=1, inUse=0, avail=1, waiting=0)¬
197285 20:49:24.977 [HikariCP connection filler] DEBUG
com.zaxxer.hikari.pool.HikariPool - Connection attempt to database
HikariPool-0 failed: No suitable driver found for jdbc:postgresql://
127.0.0.1:5432/gamema
197286 java.sql.SQLException: No suitable driver found for
jdbc:postgresql://
127.0.0.1:5432/gamemachine?loginTimeout=0&socketTimeout=0&prepareThreshold=5&unknownLength=2147483647&tcpKeepAlive=false&binaryTransfe
197287 » at
java.sql.DriverManager.getConnection(DriverManager.java:596)
~[na:1.7.0_65]¬
197288 » at
java.sql.DriverManager.getConnection(DriverManager.java:215)
~[na:1.7.0_65]¬
197289 » at
org.postgresql.ds.common.BaseDataSource.getConnection(BaseDataSource.java:99)
~[postgresql-9.3-1102-jdbc41.jar:na]¬
197290 » at
org.postgresql.ds.common.BaseDataSource.getConnection(BaseDataSource.java:82)
~[postgresql-9.3-1102-jdbc41.jar:na]¬
197291 » at
com.zaxxer.hikari.pool.HikariPool.addConnection(HikariPool.java:399)
[HikariCP-java6-2.0.1.jar:na]¬
197292 » at
com.zaxxer.hikari.pool.HikariPool.access$400(HikariPool.java:64)
[HikariCP-java6-2.0.1.jar:na]¬
197293 » at
com.zaxxer.hikari.pool.HikariPool$1AddConnection.run(HikariPool.java:316)
[HikariCP-java6-2.0.1.jar:na]¬
197294 » at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
[na:1.7.0_65]¬
197295 » at java.util.concurrent.FutureTask.run(FutureTask.java:262)
[na:1.7.0_65]¬
197296 » at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
[na:1.7.0_65]¬
197297 » at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
[na:1.7.0_65]¬
Chris
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.