You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/06/21 13:27:06 UTC

[GitHub] [shardingsphere] linghengqian opened a new issue, #18495: Unable to configure `dataSource` property for HikariCP 4.0.3

linghengqian opened a new issue, #18495:
URL: https://github.com/apache/shardingsphere/issues/18495

   ## Question
   
   **For English only**, other languages will not accept.
   
   Before asking a question, make sure you have:
   
   - Googled your question.
   - Searched open and closed [GitHub issues](https://github.com/apache/shardingsphere/issues).
   - Read documentation: [ShardingSphere Doc](https://shardingsphere.apache.org/document/current/en/overview).
   
   Please pay attention on issues you submitted, because we maybe need more details. 
   If no response anymore and we cannot reproduce it on current information, we will **close it**.
   
   - For ShardingSphere 5.1.2, configuring the `dataSource` property of HikariCP 4.0.3 throws an exception, is this intentional?
   ```yaml
   spring:
     shardingsphere:
       schema:
         name: "sharding_db"
       mode:
         type: Memory
       datasource:
         names: ds-0
         ds-0:
           type: com.zaxxer.hikari.HikariDataSource
           driver-class-name: com.mysql.cj.jdbc.Driver
           jdbc-url: jdbc:mysql://localhost:3306/testdb?serverTimezone=GMT%2b8&useUnicode=true&characterEncoding=UTF-8
           username: root
           password: 123456
           dataSource:
             cachePrepStmts: true
             prepStmtCacheSize: 250
             prepStmtCacheSqlLimit: 2048
             useServerPrepStmts: true
             useLocalSessionState: true
             rewriteBatchedStatements: true
             cacheResultSetMetadata: true
             cacheServerConfiguration: true
             elideSetAutoCommits: true
             maintainTimeStats: false
   ```
   - An exception will be thrown.
   ```shell
   2022-06-21 21:22:42.079  WARN 14124 --- [  restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.shardingsphere.spring.boot.ShardingSphereAutoConfiguration': Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: argument type mismatch
   2022-06-21 21:22:42.095  INFO 14124 --- [  restartedMain] ConditionEvaluationReportLoggingListener : 
   
   Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
   2022-06-21 21:22:42.126 ERROR 14124 --- [  restartedMain] o.s.boot.SpringApplication               : Application run failed
   
   org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.shardingsphere.spring.boot.ShardingSphereAutoConfiguration': Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: argument type mismatch
   	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:628) ~[spring-beans-5.3.20.jar:5.3.20]
   	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.20.jar:5.3.20]
   	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.20.jar:5.3.20]
   	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.20.jar:5.3.20]
   	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.20.jar:5.3.20]
   	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.20.jar:5.3.20]
   	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:410) ~[spring-beans-5.3.20.jar:5.3.20]
   	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352) ~[spring-beans-5.3.20.jar:5.3.20]
   	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195) ~[spring-beans-5.3.20.jar:5.3.20]
   	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[spring-beans-5.3.20.jar:5.3.20]
   	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.20.jar:5.3.20]
   	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.20.jar:5.3.20]
   	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.20.jar:5.3.20]
   	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.20.jar:5.3.20]
   	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:213) ~[spring-beans-5.3.20.jar:5.3.20]
   	at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:258) ~[spring-context-5.3.20.jar:5.3.20]
   	at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:762) ~[spring-context-5.3.20.jar:5.3.20]
   	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:567) ~[spring-context-5.3.20.jar:5.3.20]
   	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) ~[spring-boot-2.7.0.jar:2.7.0]
   	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) [spring-boot-2.7.0.jar:2.7.0]
   	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) [spring-boot-2.7.0.jar:2.7.0]
   	at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) [spring-boot-2.7.0.jar:2.7.0]
   	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) [spring-boot-2.7.0.jar:2.7.0]
   	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) [spring-boot-2.7.0.jar:2.7.0]
   	at com.lingh.test.LinghTestApplication.main(LinghTestApplication.java:19) [classes/:na]
   	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_332]
   	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_332]
   	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_332]
   	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_332]
   	at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.7.0.jar:2.7.0]
   Caused by: java.lang.IllegalArgumentException: argument type mismatch
   	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_332]
   	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_332]
   	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_332]
   	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_332]
   	at org.apache.shardingsphere.infra.datasource.pool.creator.DataSourceReflection.setField(DataSourceReflection.java:144) ~[shardingsphere-infra-common-5.1.2.jar:5.1.2]
   	at org.apache.shardingsphere.infra.datasource.pool.creator.DataSourceReflection.lambda$setField$0(DataSourceReflection.java:123) ~[shardingsphere-infra-common-5.1.2.jar:5.1.2]
   	at java.util.Optional.ifPresent(Optional.java:159) ~[na:1.8.0_332]
   	at org.apache.shardingsphere.infra.datasource.pool.creator.DataSourceReflection.setField(DataSourceReflection.java:123) ~[shardingsphere-infra-common-5.1.2.jar:5.1.2]
   	at org.apache.shardingsphere.infra.datasource.pool.creator.DataSourcePoolCreator.setConfiguredFields(DataSourcePoolCreator.java:126) ~[shardingsphere-infra-common-5.1.2.jar:5.1.2]
   	at org.apache.shardingsphere.infra.datasource.pool.creator.DataSourcePoolCreator.create(DataSourcePoolCreator.java:79) ~[shardingsphere-infra-common-5.1.2.jar:5.1.2]
   	at org.apache.shardingsphere.spring.boot.datasource.DataSourceMapSetter.getDataSource(DataSourceMapSetter.java:92) ~[shardingsphere-jdbc-spring-boot-starter-infra-5.1.2.jar:5.1.2]
   	at org.apache.shardingsphere.spring.boot.datasource.DataSourceMapSetter.getDataSourceMap(DataSourceMapSetter.java:65) ~[shardingsphere-jdbc-spring-boot-starter-infra-5.1.2.jar:5.1.2]
   	at org.apache.shardingsphere.spring.boot.ShardingSphereAutoConfiguration.setEnvironment(ShardingSphereAutoConfiguration.java:122) ~[shardingsphere-jdbc-core-spring-boot-starter-5.1.2.jar:5.1.2]
   	at org.springframework.context.support.ApplicationContextAwareProcessor.invokeAwareInterfaces(ApplicationContextAwareProcessor.java:110) ~[spring-context-5.3.20.jar:5.3.20]
   	at org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:102) ~[spring-context-5.3.20.jar:5.3.20]
   	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:440) ~[spring-beans-5.3.20.jar:5.3.20]
   	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796) ~[spring-beans-5.3.20.jar:5.3.20]
   	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.20.jar:5.3.20]
   	... 29 common frames omitted
   
   ```
   - The `dataSource` property is from https://github.com/brettwooldridge/HikariCP#infrequently-used .
   - 
   ![image](https://user-images.githubusercontent.com/20187731/174809390-ef406799-2691-4804-861a-2539aa81b657.png)
   - The configuration used is from https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration .
   - Or is there another name for this property? Am I missing something in the HikariCP or ShardingSphere documentation?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] linghengqian commented on issue #18495: Unable to configure `dataSource` property for HikariCP 4.0.3

Posted by GitBox <gi...@apache.org>.
linghengqian commented on issue #18495:
URL: https://github.com/apache/shardingsphere/issues/18495#issuecomment-1161847691

   @zjcnb Thank you very much! But I'm still curious if the property name `data-source-properties` comes from ShardingSphere custom, or is it a HikariCP configuration name somewhere?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] linghengqian closed issue #18495: Unable to configure `dataSource` property for HikariCP 4.0.3

Posted by GitBox <gi...@apache.org>.
linghengqian closed issue #18495: Unable to configure `dataSource` property for HikariCP 4.0.3
URL: https://github.com/apache/shardingsphere/issues/18495


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] linghengqian commented on issue #18495: Unable to configure `dataSource` property for HikariCP 4.0.3

Posted by GitBox <gi...@apache.org>.
linghengqian commented on issue #18495:
URL: https://github.com/apache/shardingsphere/issues/18495#issuecomment-1162582886

   - Just as an update: this property name is not a custom name for `ShardingSphere`, it is taken from:
   https://github.com/brettwooldridge/HikariCP/blob/HikariCP-4.0.3/src/main/java/com/zaxxer/hikari/HikariConfig.java#L96 
   
   - This property is implicitly mentioned in `jdbcUrl` in https://github.com/brettwooldridge/HikariCP#essentials , and there is a related issue at https://github.com/brettwooldridge/HikariCP/issues/1851 .


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] linghengqian commented on issue #18495: Unable to configure `dataSource` property for HikariCP 4.0.3

Posted by GitBox <gi...@apache.org>.
linghengqian commented on issue #18495:
URL: https://github.com/apache/shardingsphere/issues/18495#issuecomment-1161855868

   > I think it is `ShardingSphere` custom properties.
   
   Thank you! I will close this issue.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] zjcnb commented on issue #18495: Unable to configure `dataSource` property for HikariCP 4.0.3

Posted by GitBox <gi...@apache.org>.
zjcnb commented on issue #18495:
URL: https://github.com/apache/shardingsphere/issues/18495#issuecomment-1161854581

   I think it is `ShardingSphere` custom properties.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] zjcnb commented on issue #18495: Unable to configure `dataSource` property for HikariCP 4.0.3

Posted by GitBox <gi...@apache.org>.
zjcnb commented on issue #18495:
URL: https://github.com/apache/shardingsphere/issues/18495#issuecomment-1161842901

   @linghengqian Hou about this way?
   
   ```
   localhost: localhost
   
   
   spring:
     shardingsphere:
       dataSource:
         names: ds0, ds1
         ds0:
           type: com.zaxxer.hikari.HikariDataSource
           driverClassName: com.mysql.cj.jdbc.Driver
           jdbcUrl: jdbc:mysql://${localhost}:3306/ds0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
           username: root
           password: 123456
           poolName: datasource-one
           data-source-properties:
             cachePrepStmts: true
             prepStmtCacheSize: 250
             prepStmtCacheSqlLimit: 2048
             useServerPrepStmts: true
             useLocalSessionState: true
             rewriteBatchedStatements: true
             cacheResultSetMetadata: true
             cacheServerConfiguration: true
             elideSetAutoCommits: true
             maintainTimeStats: false
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org