brettwooldridge / HikariCP

光 HikariCP・A solid, high-performance, JDBC connection pool at last.
Apache License 2.0
20.04k stars 2.94k forks source link

Pool Initialization Issue w/ PostGIS #1476

Open linoborsoto1 opened 5 years ago

linoborsoto1 commented 5 years ago

Environment

HikariCP version: 3.4.1
JDK version     : 1.8.0_141
Database        : PostgreSQL
Driver version  : 42.2.8

⚠️ Please verify that your issue still occurs on the latest version of HikariCP before reporting.

We're using PostGIS 2.3.0 as an add-on library, and we're getting this error on startup:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'masterDataSource' defined in com.vistracks.tracking.datasource.DataSourceConfig: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'masterDataSource' threw exception; nested exception is com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to initialize pool: Something unusual has occurred to cause the driver to fail. Please report this exception. at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1128) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1022) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:512) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351) ... 106 more Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'masterDataSource' threw exception; nested exception is com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to initialize pool: Something unusual has occurred to cause the driver to fail. Please report this exception. at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189) at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588) ... 115 more Caused by: com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to initialize pool: Something unusual has occurred to cause the driver to fail. Please report this exception. at com.zaxxer.hikari.pool.HikariPool.throwPoolInitializationException(HikariPool.java:597) at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:576) at com.zaxxer.hikari.pool.HikariPool.(HikariPool.java:115) at com.zaxxer.hikari.HikariDataSource.(HikariDataSource.java:81) at com.vistracks.tracking.datasource.DataSourceConfig.masterDataSource(DataSourceConfig.java:93) at com.vistracks.tracking.datasource.DataSourceConfig$$EnhancerBySpringCGLIB$$4e2cc2b3.CGLIB$masterDataSource$1() at com.vistracks.tracking.datasource.DataSourceConfig$$EnhancerBySpringCGLIB$$4e2cc2b3$$FastClassBySpringCGLIB$$df83cc8f.invoke() at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:356) at com.vistracks.tracking.datasource.DataSourceConfig$$EnhancerBySpringCGLIB$$4e2cc2b3.masterDataSource() at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) ... 116 more Caused by: org.postgresql.util.PSQLException: Something unusual has occurred to cause the driver to fail. Please report this exception. at org.postgresql.Driver.connect(Driver.java:281) at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138) at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:353) at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:201) at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:473) at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:562) ... 129 more Caused by: java.lang.ClassCastException: class org.postgis.PGbox3d at java.lang.Class.asSubclass(Class.java:3404) at org.postgresql.jdbc.PgConnection.initObjectTypes(PgConnection.java:648) at org.postgresql.jdbc.PgConnection.(PgConnection.java:266) at org.postgresql.Driver.makeConnection(Driver.java:458) at org.postgresql.Driver.connect(Driver.java:260)


Have you searched the CLOSED issues already? How about checking stackoverflow?

nunnrlc commented 5 years ago

Looks like an issue with postgresql driver. This part is important:

Caused by: org.postgresql.util.PSQLException: Something unusual has occurred to cause the driver to fail. Please report this exception.
at org.postgresql.Driver.connect(Driver.java:281)
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138)
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:353)
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:201)
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:473)
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:562)
... 129 more
Caused by: java.lang.ClassCastException: class org.postgis.PGbox3d
at java.lang.Class.asSubclass(Class.java:3404)
at org.postgresql.jdbc.PgConnection.initObjectTypes(PgConnection.java:648)
at org.postgresql.jdbc.PgConnection.(PgConnection.java:266)
at org.postgresql.Driver.makeConnection(Driver.java:458)
at org.postgresql.Driver.connect(Driver.java:260)

java.lang.ClassCastException does sound like a bug!

Please ask over on https://github.com/pgjdbc/pgjdbc

davecramer commented 5 years ago

@nunnrlc Well the PostgreSQL JDBC driver doesn't actually provide the postgis classes so while it's an issue it's not a bug in the driver.

nunnrlc commented 5 years ago

Ah, yes I missed that!

@linoborsoto1 as you are using the latest postgresql jdbc version, you likely need a much newer postgis version also. Version 2.3 of postgis is from 2016. Version 3 is current now.

Best of luck.

linoborsoto1 commented 5 years ago

I'm using this: https://mvnrepository.com/artifact/net.postgis/postgis-jdbc Their latest version is 2.3.0. And their last commit is from Nov last year.