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


   ## Feature Request
   
   **For English only**, other languages will not accept.
   
   Please pay attention on issues you submitted, because we maybe need more 
details. 
   If no response anymore and we cannot make decision by current information, 
we will **close it**.
   
   Please answer these questions before submitting your issue. Thanks!
   
   ### Is your feature request related to a problem?
   
   No.
   
   ### Describe the feature you would like.
   
   In ShardingSphere `5.1.0`, using the JDBC pool is required to have multiple 
classes that implements its corresponding metadata SPI. This is available at 
https://shardingsphere.apache.org/document/current/en/dev-manual/data-source/ 
manifested, but not obvious.
   
   Under the `org.apache.shardingsphere.infra.datasource.pool.metadata.type` 
package, three JDBC pools such as `DBCP`, `HikariCP`, `Tomcat JDBC Pool` are 
integrated by default, and implements the corresponding 
`org.apache.shardingsphere.infra.datasource.pool.metadata.DataSourcePoolMetaData`
 and 
`org.apache.shardingsphere.infra.datasource.pool.metadata.DataSourceJdbcUrlMetaData`
 interfaces. In addition, for `HikariCP`, it also implements the 
`org.apache.shardingsphere.infra.datasource.pool.destroyer.DataSourcePoolDestroyer`
 interface.
   
   
![image](https://user-images.githubusercontent.com/20187731/154699793-937d48ca-42b3-4dde-bede-58a7c3e21fe6.png)
   
   In the case of using a third-party `JDBC pool` that does not implement the 
metadata SPI (using `Alibaba Druid` as an example), the information the user 
gets is not clear. The user is likely to get something like this.
   
   ```shell
   Caused by: java.lang.NoClassDefFoundError: 
org/apache/tomcat/dbcp/dbcp2/BasicDataSource
        at 
org.apache.shardingsphere.infra.datasource.pool.metadata.type.dbcp.TomcatDBCPDataSourcePoolMetaData.getType(TomcatDBCPDataSourcePoolMetaData.java:67)
 ~[shardingsphere-infra-common-5.1.0.jar:5.1.0]
        at 
org.apache.shardingsphere.spi.typed.TypedSPIRegistry.lambda$findRegisteredService$0(TypedSPIRegistry.java:44)
 ~[shardingsphere-spi-5.1.0.jar:5.1.0]
        at 
java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:174) 
~[na:1.8.0_312]
        at 
java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1361) 
~[na:1.8.0_312]
        at 
java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
 ~[na:1.8.0_312]
        at 
java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:499) 
~[na:1.8.0_312]
        at 
java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:486) 
~[na:1.8.0_312]
        at 
java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) 
~[na:1.8.0_312]
        at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152) 
~[na:1.8.0_312]
        at 
java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) 
~[na:1.8.0_312]
        at 
java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:531) 
~[na:1.8.0_312]
        at 
org.apache.shardingsphere.spi.typed.TypedSPIRegistry.findRegisteredService(TypedSPIRegistry.java:44)
 ~[shardingsphere-spi-5.1.0.jar:5.1.0]
        at 
org.apache.shardingsphere.infra.datasource.pool.metadata.DataSourcePoolMetaDataFactory.newInstance(DataSourcePoolMetaDataFactory.java:46)
 ~[shardingsphere-infra-common-5.1.0.jar:5.1.0]
        at 
org.apache.shardingsphere.infra.datasource.props.DataSourceProperties.<init>(DataSourceProperties.java:53)
 ~[shardingsphere-infra-common-5.1.0.jar:5.1.0]
        at 
org.apache.shardingsphere.spring.boot.datasource.DataSourceMapSetter.getDataSource(DataSourceMapSetter.java:92)
 ~[shardingsphere-jdbc-spring-boot-starter-infra-5.1.0.jar:5.1.0]
        at 
org.apache.shardingsphere.spring.boot.datasource.DataSourceMapSetter.getDataSourceMap(DataSourceMapSetter.java:65)
 ~[shardingsphere-jdbc-spring-boot-starter-infra-5.1.0.jar:5.1.0]
        at 
org.apache.shardingsphere.spring.boot.ShardingSphereAutoConfiguration.setEnvironment(ShardingSphereAutoConfiguration.java:122)
 ~[shardingsphere-jdbc-core-spring-boot-starter-5.1.0.jar:5.1.0]
        at 
org.springframework.context.support.ApplicationContextAwareProcessor.invokeAwareInterfaces(ApplicationContextAwareProcessor.java:110)
 ~[spring-context-5.3.15.jar:5.3.15]
        at 
org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:102)
 ~[spring-context-5.3.15.jar:5.3.15]
        at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:440)
 ~[spring-beans-5.3.15.jar:5.3.15]
        at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796)
 ~[spring-beans-5.3.15.jar:5.3.15]
        at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620)
 ~[spring-beans-5.3.15.jar:5.3.15]
        ... 29 common frames omitted
   Caused by: java.lang.ClassNotFoundException: 
org.apache.tomcat.dbcp.dbcp2.BasicDataSource
        at java.net.URLClassLoader.findClass(URLClassLoader.java:387) 
~[na:1.8.0_312]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:418) ~[na:1.8.0_312]
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352) 
~[na:1.8.0_312]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[na:1.8.0_312]
        ... 51 common frames omitted
   ```
   
   I think an example can be added at 
https://github.com/apache/shardingsphere/tree/master/examples to provide users 
with reference. I believe this is also helpful to users of `C3P0` and `BeeCP`.


-- 
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]


Reply via email to