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 2021/04/29 02:03:43 UTC

[GitHub] [shardingsphere] hanxu00920 opened a new issue #10216: ShardingSphere-JDBC orchestration for Spring boot not available

hanxu00920 opened a new issue #10216:
URL: https://github.com/apache/shardingsphere/issues/10216


   ### Which version of ShardingSphere did you use?
   4.1.1
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   ShardingSphere-JDBC
   ### Expected behavior
   zookeeper for configuration sharing 
   ### Actual behavior
   springboot application fails to start,fails logs:
   ```
   ***************************
   APPLICATION FAILED TO START
   ***************************
   
   Description:
   
   Failed to bind properties under 'spring.shardingsphere.orchestration.name' to org.apache.shardingsphere.orchestration.center.yaml.config.YamlCenterRepositoryConfiguration:
   
       Property: spring.shardingsphere.orchestration.name
       Value: spring_boot_ds_sharding
       Origin: class path resource [application-dev.properties]:53:42
       Reason: No converter found capable of converting from type [java.lang.String] to type [org.apache.shardingsphere.orchestration.center.yaml.config.YamlCenterRepositoryConfiguration]
   
   Action:
   
   Update your application's configuration
   ```
   ### Reason analyze (If you can)
   I read document, can't explain why the error.
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   **maven dependencies:**
   ```
   <dependency> 
     <groupId>org.apache.shardingsphere</groupId>  
     <artifactId>sharding-jdbc-orchestration-spring-boot-starter</artifactId>  
     <version>${shardingsphere.version}</version> 
   </dependency>
   
   <dependency> 
     <groupId>org.apache.shardingsphere</groupId>  
     <artifactId>sharding-orchestration-center-zookeeper-curator</artifactId>  
     <version>${shardingsphere.version}</version> 
   </dependency>
   
   ```
   **springboot version:**
       2.0.3.RELEASE
   **spring applaction.properties:**
   ```
   spring.shardingsphere.datasource.names=ds0,ds1
   
   spring.shardingsphere.datasource.ds0.type=com.zaxxer.hikari.HikariDataSource
   spring.shardingsphere.datasource.ds0.driver-class-name=org.postgresql.Driver
   spring.shardingsphere.datasource.ds0.jdbc-url=jdbc:postgresql://hxvm1:5432/postgres
   spring.shardingsphere.datasource.ds0.username=postgres
   spring.shardingsphere.datasource.ds0.password=
   
   spring.shardingsphere.datasource.ds1.type=com.zaxxer.hikari.HikariDataSource
   spring.shardingsphere.datasource.ds1.driver-class-name=org.postgresql.Driver
   spring.shardingsphere.datasource.ds1.jdbc-url=jdbc:postgresql://hxvm2:5432/postgres
   spring.shardingsphere.datasource.ds1.username=postgres
   spring.shardingsphere.datasource.ds1.password=
   
   spring.shardingsphere.sharding.tables.t_order.actual-data-nodes=ds$->{0..1}.cd_order_info
   spring.shardingsphere.sharding.tables.cd_order_info.database-strategy.standard.sharding-column=ordernum
   spring.shardingsphere.sharding.tables.cd_order_info.database-strategy.standard.precise-algorithm-class-name=com.post.trade.shading.OrderNumAlgorithm
   spring.shardingsphere.sharding.tables.cd_order_info.key-generator.column=order_id
   spring.shardingsphere.sharding.tables.cd_order_info.key-generator.type=SNOWFLAKE
   
   spring.shardingsphere.sharding.tables.cd_trans_serial_info.actual-data-nodes=ds$->{0..1}.cd_trans_serial_info
   
   spring.shardingsphere.sharding.tables.cd_trans_serial_info.database-strategy.standard.sharding-column=ordernum
   spring.shardingsphere.sharding.tables.cd_trans_serial_info.database-strategy.standard.precise-algorithm-class-name=com.post.trade.shading.OrderNumAlgorithm
   spring.shardingsphere.sharding.tables.cd_trans_serial_info.key-generator.column=serial_id
   spring.shardingsphere.sharding.tables.cd_trans_serial_info.key-generator.type=SNOWFLAKE
   
   spring.shardingsphere.props.sql.show=true
   
   spring.shardingsphere.orchestration.name=spring_boot_ds_sharding
   spring.shardingsphere.orchestration.overwrite=true
   spring.shardingsphere.orchestration.registry.type=zookeeper
   spring.shardingsphere.orchestration.registry.namespace=orchestration-spring-boot-sharding-test
   spring.shardingsphere.orchestration.registry.server-lists=localhost:2181
   ```
   


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

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



[GitHub] [shardingsphere] tristaZero commented on issue #10216: ShardingSphere-JDBC orchestration for Spring boot not available

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


   @hanxu00920 Concise description. 
   Your configuration is based on [Configurations](https://shardingsphere.apache.org/document/legacy/4.x/document/cn/manual/sharding-jdbc/configuration/config-spring-boot/) but still does not work, right?
   Plus, [exmpales](https://github.com/apache/shardingsphere/tree/4.1.1/examples/sharding-jdbc-example/orchestration-example) is a good reference for you.


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

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



[GitHub] [shardingsphere] terrymanu closed issue #10216: ShardingSphere-JDBC orchestration for Spring boot not available

Posted by GitBox <gi...@apache.org>.
terrymanu closed issue #10216:
URL: https://github.com/apache/shardingsphere/issues/10216


   


-- 
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] hanxu00920 commented on issue #10216: ShardingSphere-JDBC orchestration for Spring boot not available

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


   > @hanxu00920 Concise description.
   > Your configuration is based on [Configurations](https://shardingsphere.apache.org/document/legacy/4.x/document/cn/manual/sharding-jdbc/configuration/config-spring-boot/) but still does not work, right?
   > Plus, [exmpales](https://github.com/apache/shardingsphere/tree/4.1.1/examples/sharding-jdbc-example/orchestration-example) is a good reference for you.
   
   https://github.com/hanxu00920/shardingsphere-jdbc-demo


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

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



[GitHub] [shardingsphere] terrymanu commented on issue #10216: ShardingSphere-JDBC orchestration for Spring boot not available

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


   The example is there, maybe you can check it first, thank you


-- 
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] hanxu00920 removed a comment on issue #10216: ShardingSphere-JDBC orchestration for Spring boot not available

Posted by GitBox <gi...@apache.org>.
hanxu00920 removed a comment on issue #10216:
URL: https://github.com/apache/shardingsphere/issues/10216#issuecomment-828918784


   Did you really test and use a hybrid architecture?
   I googled other people's examples, and tried to use the 4.0.1 version of the dependency, and excluded many of the dependencies he said. 
   ```
   <dependency>
   	<groupId>org.apache.shardingsphere</groupId>
   	<artifactId>sharding-jdbc-orchestration-spring-boot-starter</artifactId>
   	<version>4.0.1</version>
   	<exclusions>
   		<exclusion>
   			<groupId>org.apache.curator</groupId>
   			<artifactId>curator-framework</artifactId>
   		</exclusion>
   	</exclusions>
   </dependency>
   <dependency>
   	<groupId>org.apache.shardingsphere</groupId>
   	<artifactId>sharding-orchestration-reg-zookeeper-curator</artifactId>
   	<version>4.0.1</version>
   	<exclusions>
   		<exclusion>
   			<groupId>org.apache.curator</groupId>
   			<artifactId>curator-framework</artifactId>
   		</exclusion>
   		<exclusion>
   			<groupId>org.apache.curator</groupId>
   			<artifactId>curator-recipes</artifactId>
   		</exclusion>
   		<exclusion>
   			<groupId>org.apache.curator</groupId>
   			<artifactId>curator-client</artifactId>
   		</exclusion>
   	</exclusions>
   </dependency>
   <dependency>
   	<groupId>org.apache.curator</groupId>
   	<artifactId>curator-framework</artifactId>
   	<version>2.10.0</version>
   </dependency>
   <dependency>
   	<groupId>org.apache.curator</groupId>
   	<artifactId>curator-recipes</artifactId>
   	<version>2.10.0</version>
   </dependency>
   ```
   The jdbc application is successfully started and the configuration is shared to zookeeper, but the shardingsphere-proxy cannot be started through the configuration center.
   proxy error log:
   ```
   Exception in thread "main" java.lang.NullPointerException
   	at java.util.regex.Matcher.getTextLength(Matcher.java:1283)
   	at java.util.regex.Matcher.reset(Matcher.java:309)
   	at java.util.regex.Matcher.<init>(Matcher.java:229)
   	at java.util.regex.Pattern.matcher(Pattern.java:1093)
   	at org.yaml.snakeyaml.reader.StreamReader.checkPrintable(StreamReader.java:64)
   	at org.yaml.snakeyaml.reader.StreamReader.<init>(StreamReader.java:47)
   	at org.yaml.snakeyaml.Yaml.loadAs(Yaml.java:427)
   	at org.apache.shardingsphere.underlying.common.yaml.engine.YamlEngine.unmarshal(YamlEngine.java:129)
   	at org.apache.shardingsphere.underlying.common.yaml.engine.YamlEngine.unmarshal(YamlEngine.java:116)
   	at org.apache.shardingsphere.orchestration.core.configcenter.ConfigCenter.loadAuthentication(ConfigCenter.java:292)
   	at org.apache.shardingsphere.shardingproxy.Bootstrap.startWithRegistryCenter(Bootstrap.java:133)
   	at org.apache.shardingsphere.shardingproxy.Bootstrap.main(Bootstrap.java:87)
   ```
   So I first emptied the configuration center, and then shared the configuration to zookeeper through shardingsphere-proxy, but the jdbc application failed to start.
   jdbc error log:
   ```
   Caused by: java.lang.NullPointerException
   	at org.apache.shardingsphere.orchestration.internal.registry.config.service.ConfigurationService.isEncryptRule(ConfigurationService.java:194)
   	at org.apache.shardingsphere.shardingjdbc.orchestration.spring.boot.OrchestrationSpringBootConfiguration.dataSource(OrchestrationSpringBootConfiguration.java:175)
   	at org.apache.shardingsphere.shardingjdbc.orchestration.spring.boot.OrchestrationSpringBootConfiguration$$EnhancerBySpringCGLIB$$f6d755b2.CGLIB$dataSource$4(<generated>)
   	at org.apache.shardingsphere.shardingjdbc.orchestration.spring.boot.OrchestrationSpringBootConfiguration$$EnhancerBySpringCGLIB$$f6d755b2$$FastClassBySpringCGLIB$$891609a6.invoke(<generated>)
   	at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
   	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361)
   	at org.apache.shardingsphere.shardingjdbc.orchestration.spring.boot.OrchestrationSpringBootConfiguration$$EnhancerBySpringCGLIB$$f6d755b2.dataSource(<generated>)
   	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:154)
   	... 44 more
   ```
   I guarantee that the orchestration.name and registry.namespace configurations are accurate, and that jdbc and proxy match.
   It's really hard.


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

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



[GitHub] [shardingsphere] hanxu00920 commented on issue #10216: ShardingSphere-JDBC orchestration for Spring boot not available

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


   Did you really test and use a hybrid architecture?
   I googled other people's examples, and tried to use the 4.0.1 version of the dependency, and excluded many of the dependencies he said. 
   ```
   <dependency>
   	<groupId>org.apache.shardingsphere</groupId>
   	<artifactId>sharding-jdbc-orchestration-spring-boot-starter</artifactId>
   	<version>4.0.1</version>
   	<exclusions>
   		<exclusion>
   			<groupId>org.apache.curator</groupId>
   			<artifactId>curator-framework</artifactId>
   		</exclusion>
   	</exclusions>
   </dependency>
   <dependency>
   	<groupId>org.apache.shardingsphere</groupId>
   	<artifactId>sharding-orchestration-reg-zookeeper-curator</artifactId>
   	<version>4.0.1</version>
   	<exclusions>
   		<exclusion>
   			<groupId>org.apache.curator</groupId>
   			<artifactId>curator-framework</artifactId>
   		</exclusion>
   		<exclusion>
   			<groupId>org.apache.curator</groupId>
   			<artifactId>curator-recipes</artifactId>
   		</exclusion>
   		<exclusion>
   			<groupId>org.apache.curator</groupId>
   			<artifactId>curator-client</artifactId>
   		</exclusion>
   	</exclusions>
   </dependency>
   <dependency>
   	<groupId>org.apache.curator</groupId>
   	<artifactId>curator-framework</artifactId>
   	<version>2.10.0</version>
   </dependency>
   <dependency>
   	<groupId>org.apache.curator</groupId>
   	<artifactId>curator-recipes</artifactId>
   	<version>2.10.0</version>
   </dependency>
   ```
   The jdbc application is successfully started and the configuration is shared to zookeeper, but the shardingsphere-proxy cannot be started through the configuration center.
   proxy error log:
   ```
   Exception in thread "main" java.lang.NullPointerException
   	at java.util.regex.Matcher.getTextLength(Matcher.java:1283)
   	at java.util.regex.Matcher.reset(Matcher.java:309)
   	at java.util.regex.Matcher.<init>(Matcher.java:229)
   	at java.util.regex.Pattern.matcher(Pattern.java:1093)
   	at org.yaml.snakeyaml.reader.StreamReader.checkPrintable(StreamReader.java:64)
   	at org.yaml.snakeyaml.reader.StreamReader.<init>(StreamReader.java:47)
   	at org.yaml.snakeyaml.Yaml.loadAs(Yaml.java:427)
   	at org.apache.shardingsphere.underlying.common.yaml.engine.YamlEngine.unmarshal(YamlEngine.java:129)
   	at org.apache.shardingsphere.underlying.common.yaml.engine.YamlEngine.unmarshal(YamlEngine.java:116)
   	at org.apache.shardingsphere.orchestration.core.configcenter.ConfigCenter.loadAuthentication(ConfigCenter.java:292)
   	at org.apache.shardingsphere.shardingproxy.Bootstrap.startWithRegistryCenter(Bootstrap.java:133)
   	at org.apache.shardingsphere.shardingproxy.Bootstrap.main(Bootstrap.java:87)
   ```
   So I first emptied the configuration center, and then shared the configuration to zookeeper through shardingsphere-proxy, but the jdbc application failed to start.
   jdbc error log:
   ```
   Caused by: java.lang.NullPointerException
   	at org.apache.shardingsphere.orchestration.internal.registry.config.service.ConfigurationService.isEncryptRule(ConfigurationService.java:194)
   	at org.apache.shardingsphere.shardingjdbc.orchestration.spring.boot.OrchestrationSpringBootConfiguration.dataSource(OrchestrationSpringBootConfiguration.java:175)
   	at org.apache.shardingsphere.shardingjdbc.orchestration.spring.boot.OrchestrationSpringBootConfiguration$$EnhancerBySpringCGLIB$$f6d755b2.CGLIB$dataSource$4(<generated>)
   	at org.apache.shardingsphere.shardingjdbc.orchestration.spring.boot.OrchestrationSpringBootConfiguration$$EnhancerBySpringCGLIB$$f6d755b2$$FastClassBySpringCGLIB$$891609a6.invoke(<generated>)
   	at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
   	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361)
   	at org.apache.shardingsphere.shardingjdbc.orchestration.spring.boot.OrchestrationSpringBootConfiguration$$EnhancerBySpringCGLIB$$f6d755b2.dataSource(<generated>)
   	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:154)
   	... 44 more
   ```
   I guarantee that the orchestration.name and registry.namespace configurations are accurate, and that jdbc and proxy match.
   It's really hard.


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

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