You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Sachs, Andreas" <a....@sachs-net.de> on 2022/09/06 17:24:46 UTC

How to release database connections? / Bug eating up all database connections

Hello, 
i am not sure if this is a bug or if I use it the wrong way.

I am using velocity engine in "Separate Instance mode" (https://velocity.apache.org/engine/2.3/developer-guide.html#to-singleton-or-not-to-singleton) and i'm running out of database connections.

It looks like, that connections are only closed by the garbage collector. How can I force velocity engine to release the database connection?


DataSourceResourceLoader:
protected void finalize()
        throws Throwable
    {
        closeDBConnection();
    }



2022-09-06 07:00:31 [QuartzScheduler_Worker-8] ERROR org.apache.velocity.loader.ds - DataSourceResourceLoader: database problem while getting resource 'velocimacros.vtl':
org.apache.tomcat.jdbc.pool.PoolExhaustedException: [QuartzScheduler_Worker-8] Timeout: Pool empty. Unable to fetch a connection in 30 seconds, none available[size:100; busy:100; idle:0; lastwait:30000].
        at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:733) ~[tomcat-jdbc.jar:?]
        at org.apache.tomcat.jdbc.pool.ConnectionPool.getConnection(ConnectionPool.java:198) ~[tomcat-jdbc.jar:?]
        at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:136) ~[tomcat-jdbc.jar:?]
        at org.apache.velocity.runtime.resource.loader.DataSourceResourceLoader.openDBConnection(DataSourceResourceLoader.java:377) ~[velocity-engine-core-2.3.jar:2.3]
        at org.apache.velocity.runtime.resource.loader.DataSourceResourceLoader.checkDBConnection(DataSourceResourceLoader.java:390) ~[velocity-engine-core-2.3.jar:2.3]
        at org.apache.velocity.runtime.resource.loader.DataSourceResourceLoader.getResourceReader(DataSourceResourceLoader.java:265) [velocity-engine-core-2.3.jar:2.3]
        at org.apache.velocity.runtime.resource.loader.ResourceLoader.resourceExists(ResourceLoader.java:245) [velocity-engine-core-2.3.jar:2.3]
        at org.apache.velocity.runtime.resource.ResourceManagerImpl.getLoaderForResource(ResourceManagerImpl.java:598) [velocity-engine-core-2.3.jar:2.3]
        at org.apache.velocity.runtime.resource.ResourceManagerImpl.getLoaderNameForResource(ResourceManagerImpl.java:582) [velocity-engine-core-2.3.jar:2.3]
        at org.apache.velocity.runtime.RuntimeInstance.getLoaderNameForResource(RuntimeInstance.java:1741) [velocity-engine-core-2.3.jar:2.3]
        at org.apache.velocity.runtime.VelocimacroFactory.initVelocimacro(VelocimacroFactory.java:155) [velocity-engine-core-2.3.jar:2.3]
        at org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:293) [velocity-engine-core-2.3.jar:2.3]
        at org.apache.velocity.app.VelocityEngine.init(VelocityEngine.java:89) [velocity-engine-core-2.3.jar:2.3]

Thanks 
Andreas




---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org