sikygu opened a new issue, #32114:
URL: https://github.com/apache/shardingsphere/issues/32114
## Description
i encountered a NPE when start springboot project using
shardingsphere-jdbc-core-spring-boot-starter
there is no extra code except simple sharding configuration in
application.properties
## Version Info
**Here is part of my pom.xml**
```java
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring-boot.version>2.7.6</spring-boot.version>
</properties>
<dependencies>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
<version>5.1.2</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
<scope>provided</scope>
</dependency>
</dependencies>
```
## Exception Stack
```java
org.springframework.beans.factory.UnsatisfiedDependencyException: Error
creating bean with name 'dslContext' defined in class path resource
[org/springframework/boot/autoconfigure/jooq/JooqAutoConfiguration$DslContextConfiguration.class]:
Unsatisfied dependency expressed through method 'dslContext' parameter 0;
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'jooqConfiguration' defined in class path
resource
[org/springframework/boot/autoconfigure/jooq/JooqAutoConfiguration$DslContextConfiguration.class]:
Bean instantiation via factory method failed; nested exception is
org.springframework.beans.BeanInstantiationException: Failed to instantiate
[org.jooq.impl.DefaultConfiguration]: Factory method 'jooqConfiguration' threw
exception; nested exception is java.lang.NullPointerException
at
org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800)
~[spring-beans-5.3.24.jar:5.3.24]
at
org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:541)
~[spring-beans-5.3.24.jar:5.3.24]
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352)
~[spring-beans-5.3.24.jar:5.3.24]
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195)
~[spring-beans-5.3.24.jar:5.3.24]
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
~[spring-beans-5.3.24.jar:5.3.24]
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
~[spring-beans-5.3.24.jar:5.3.24]
at
org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
~[spring-beans-5.3.24.jar:5.3.24]
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
~[spring-beans-5.3.24.jar:5.3.24]
at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
~[spring-beans-5.3.24.jar:5.3.24]
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
~[spring-beans-5.3.24.jar:5.3.24]
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955)
~[spring-beans-5.3.24.jar:5.3.24]
at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
~[spring-context-5.3.24.jar:5.3.24]
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
~[spring-context-5.3.24.jar:5.3.24]
at
org.springframework.boot.SpringApplication.refresh(SpringApplication.java:731)
[spring-boot-2.7.6.jar:2.7.6]
at
org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408)
[spring-boot-2.7.6.jar:2.7.6]
at
org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
[spring-boot-2.7.6.jar:2.7.6]
at
org.springframework.boot.SpringApplication.run(SpringApplication.java:1303)
[spring-boot-2.7.6.jar:2.7.6]
at
org.springframework.boot.SpringApplication.run(SpringApplication.java:1292)
[spring-boot-2.7.6.jar:2.7.6]
at
com.example.shardingcollect.ShardingCollectApplication.main(ShardingCollectApplication.java:11)
[classes/:na]
Caused by: org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'jooqConfiguration' defined in class path resource
[org/springframework/boot/autoconfigure/jooq/JooqAutoConfiguration$DslContextConfiguration.class]:
Bean instantiation via factory method failed; nested exception is
org.springframework.beans.BeanInstantiationException: Failed to instantiate
[org.jooq.impl.DefaultConfiguration]: Factory method 'jooqConfiguration' threw
exception; nested exception is java.lang.NullPointerException
at
org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658)
~[spring-beans-5.3.24.jar:5.3.24]
at
org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:638)
~[spring-beans-5.3.24.jar:5.3.24]
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352)
~[spring-beans-5.3.24.jar:5.3.24]
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195)
~[spring-beans-5.3.24.jar:5.3.24]
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
~[spring-beans-5.3.24.jar:5.3.24]
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
~[spring-beans-5.3.24.jar:5.3.24]
at
org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
~[spring-beans-5.3.24.jar:5.3.24]
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
~[spring-beans-5.3.24.jar:5.3.24]
at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
~[spring-beans-5.3.24.jar:5.3.24]
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
~[spring-beans-5.3.24.jar:5.3.24]
at
org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
~[spring-beans-5.3.24.jar:5.3.24]
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1391)
~[spring-beans-5.3.24.jar:5.3.24]
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1311)
~[spring-beans-5.3.24.jar:5.3.24]
at
org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:887)
~[spring-beans-5.3.24.jar:5.3.24]
at
org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791)
~[spring-beans-5.3.24.jar:5.3.24]
... 18 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to
instantiate [org.jooq.impl.DefaultConfiguration]: Factory method
'jooqConfiguration' threw exception; nested exception is
java.lang.NullPointerException
at
org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
~[spring-beans-5.3.24.jar:5.3.24]
at
org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)
~[spring-beans-5.3.24.jar:5.3.24]
... 32 common frames omitted
Caused by: java.lang.NullPointerException: null
at
org.apache.shardingsphere.driver.jdbc.adapter.AdaptedDatabaseMetaData.getURL(AdaptedDatabaseMetaData.java:36)
~[shardingsphere-jdbc-core-5.1.2.jar:5.1.2]
at
org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:360)
~[spring-jdbc-5.3.24.jar:5.3.24]
at
org.springframework.boot.autoconfigure.jooq.SqlDialectLookup.getDialect(SqlDialectLookup.java:54)
~[spring-boot-autoconfigure-2.7.6.jar:2.7.6]
at
org.springframework.boot.autoconfigure.jooq.JooqProperties.determineSqlDialect(JooqProperties.java:58)
~[spring-boot-autoconfigure-2.7.6.jar:2.7.6]
at
org.springframework.boot.autoconfigure.jooq.JooqAutoConfiguration$DslContextConfiguration.jooqConfiguration(JooqAutoConfiguration.java:100)
~[spring-boot-autoconfigure-2.7.6.jar:2.7.6]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
~[na:1.8.0_382]
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
~[na:1.8.0_382]
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
~[na:1.8.0_382]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_382]
at
org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
~[spring-beans-5.3.24.jar:5.3.24]
... 33 common frames omitted
```
## Configuration
```java
mybatis.mapper-locations=classpath:mappers/*xml
#指定Mybatis的实体目录
mybatis.type-aliases-package=
# shardingp配置
spring.shardingsphere.datasource.ds0.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.ds0.driver-class-name=com.mysql.cj.jdbc.Driver
spring.shardingsphere.datasource.ds0.url=
spring.shardingsphere.datasource.ds0.username=
spring.shardingsphere.datasource.ds0.password=
spring.shardingsphere.datasource.ds1.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.ds1.driver-class-name=com.mysql.cj.jdbc.Driver
spring.shardingsphere.datasource.ds1.url=
spring.shardingsphere.datasource.ds1.username=
spring.shardingsphere.datasource.ds1.password=
spring.shardingsphere.datasource.ds2.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.ds2.driver-class-name=com.mysql.cj.jdbc.Driver
spring.shardingsphere.datasource.ds2.url=
spring.shardingsphere.datasource.ds2.username=
spring.shardingsphere.datasource.ds2.password=
spring.shardingsphere.datasource.ds3.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.ds3.driver-class-name=com.mysql.cj.jdbc.Driver
spring.shardingsphere.datasource.ds3.url=
spring.shardingsphere.datasource.ds3.username=
spring.shardingsphere.datasource.ds3.password=
spring.shardingsphere.sharding.tables.vendor_order.actual-data-nodes=ds$->{0..3}.t_order_$->{0..1}
spring.shardingsphere.sharding.tables.vendor_order.table-strategy.inline.sharding-column=waybill_code
spring.shardingsphere.sharding.tables.vendor_order.table-strategy.inline.algorithm-expression=vendor_order_$->{waybill_code
% 2}
spring.shardingsphere.sharding.tables.vendor_order.key-generator.column=id
spring.shardingsphere.sharding.tables.vendor_order.key-generator.type=SNOWFLAKE
spring.shardingsphere.sharding.tables.vendor_order.binding-tables=t_order_item
spring.shardingsphere.sharding.default-database-strategy.inline.sharding-column=site_code
spring.shardingsphere.sharding.default-database-strategy.inline.algorithm-expression=ds$->{site_code
% 2}
spring.shardingsphere.props.sql.show=true
spring.shardingsphere.props.query-with-cipher-column=true
spring.shardingsphere.props.executor.size=100
spring.shardingsphere.props.executor.max-connections-size-per-query=1
spring.shardingsphere.props.executor.max-threads-count=1
spring.shardingsphere.props.executor.local-executor.max-connections-size=1
spring.shardingsphere.props.transaction.type=XA
spring.shardingsphere.props.transaction.xa.datasource.names=ds0,ds1,ds2,ds3
spring.shardingsphere.props.hint.enabled=false
spring.shardingsphere.props.show.performance=true
spring.shardingsphere.props.show.sql=true
```
--
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:
[email protected]
For queries about this service, please contact Infrastructure at:
[email protected]