Repository: apache/shardingsphere
Issue: 4.0.0-RC2 sharding-proxy use zookeeper can not start

i can use zookeeper in sharding-proxy, but can not start.
server.xml:
orchestration:
  name: orchestration_ds
  overwrite: false
  registry:
    type: zookeeper
    serverLists: localhost:2181
    namespace: orchestration

error:
[INFO ] 09:54:56.858 [main] o.a.c.f.imps.CuratorFrameworkImpl - Starting
[INFO ] 09:54:56.863 [main] org.apache.zookeeper.ZooKeeper - Client environment:zookeeper.version=3.4.10-39d3a4f269333c922ed3db283be479f9deacaa0f, built on 03/23/2017 10:13 GMT
[INFO ] 09:54:56.863 [main] org.apache.zookeeper.ZooKeeper - Client environment:host.name=server02
[INFO ] 09:54:56.863 [main] org.apache.zookeeper.ZooKeeper - Client environment:java.version=1.8.0_171
[INFO ] 09:54:56.863 [main] org.apache.zookeeper.ZooKeeper - Client environment:java.vendor=Oracle Corporation
[INFO ] 09:54:56.863 [main] org.apache.zookeeper.ZooKeeper - Client environment:java.home=/usr/java/jdk1.8.0_171/jre
[INFO ] 09:54:56.863 [main] org.apache.zookeeper.ZooKeeper - Client environment:java.class.path=.:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/conf:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/sharding-proxy-bootstrap-4.0.0-RC2.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/sharding-proxy-common-4.0.0-RC2.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/sharding-core-entry-4.0.0-RC2.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/sharding-core-api-4.0.0-RC2.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/guava-18.0.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/slf4j-api-1.7.7.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/jcl-over-slf4j-1.7.7.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/sharding-core-common-4.0.0-RC2.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/groovy-2.4.5-indy.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/snakeyaml-1.16.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/commons-codec-1.10.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/sharding-core-parse-common-4.0.0-RC2.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/sharding-core-parse-spi-4.0.0-RC2.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/antlr4-runtime-4.7.1.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/commons-collections4-4.2.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/sharding-core-parse-mysql-4.0.0-RC2.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/sharding-core-parse-postgresql-4.0.0-RC2.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/sharding-core-parse-oracle-4.0.0-RC2.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/sharding-core-parse-sqlserver-4.0.0-RC2.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/sharding-core-optimize-4.0.0-RC2.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/sharding-core-route-4.0.0-RC2.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/sharding-core-rewrite-4.0.0-RC2.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/sharding-core-execute-4.0.0-RC2.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/sharding-core-merge-4.0.0-RC2.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/sharding-orchestration-core-4.0.0-RC2.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/sharding-orchestration-reg-api-4.0.0-RC2.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/HikariCP-java7-2.4.11.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/sharding-proxy-transport-core-4.0.0-RC2.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/netty-all-4.1.16.Final.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/sharding-proxy-transport-mysql-4.0.0-RC2.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/sharding-transaction-core-4.0.0-RC2.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/sharding-proxy-transport-postgresql-4.0.0-RC2.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/sharding-proxy-frontend-core-4.0.0-RC2.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/sharding-proxy-frontend-spi-4.0.0-RC2.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/sharding-proxy-backend-4.0.0-RC2.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/sharding-transaction-xa-core-4.0.0-RC2.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/sharding-transaction-xa-spi-4.0.0-RC2.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/jta-1.1.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/sharding-transaction-xa-atomikos-manager-4.0.0-RC2.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/transactions-4.0.6.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/transactions-api-4.0.6.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/atomikos-util-4.0.6.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/transactions-jta-4.0.6.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/transactions-jdbc-4.0.6.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/postgresql-42.2.5.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/sharding-proxy-frontend-mysql-4.0.0-RC2.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/sharding-proxy-frontend-postgresql-4.0.0-RC2.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/sharding-orchestration-reg-zookeeper-curator-4.0.0-RC2.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/curator-framework-2.10.0.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/curator-client-2.10.0.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/log4j-1.2.16.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/jline-0.9.94.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/curator-recipes-2.10.0.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/sharding-opentracing-4.0.0-RC2.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/opentracing-util-0.30.0.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/opentracing-api-0.30.0.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/opentracing-noop-0.30.0.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/logback-classic-1.2.0.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/logback-core-1.2.0.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/sharding-proxy-distribution-4.0.0-RC2.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/mysql-connector-java-5.1.47.jar:/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin/lib/zookeeper-3.4.10.jar
[INFO ] 09:54:56.863 [main] org.apache.zookeeper.ZooKeeper - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
[INFO ] 09:54:56.863 [main] org.apache.zookeeper.ZooKeeper - Client environment:java.io.tmpdir=/tmp
[INFO ] 09:54:56.863 [main] org.apache.zookeeper.ZooKeeper - Client environment:java.compiler=<NA>
[INFO ] 09:54:56.863 [main] org.apache.zookeeper.ZooKeeper - Client environment:os.name=Linux
[INFO ] 09:54:56.863 [main] org.apache.zookeeper.ZooKeeper - Client environment:os.arch=amd64
[INFO ] 09:54:56.863 [main] org.apache.zookeeper.ZooKeeper - Client environment:os.version=3.10.0-862.el7.x86_64
[INFO ] 09:54:56.863 [main] org.apache.zookeeper.ZooKeeper - Client environment:user.name=root
[INFO ] 09:54:56.863 [main] org.apache.zookeeper.ZooKeeper - Client environment:user.home=/root
[INFO ] 09:54:56.863 [main] org.apache.zookeeper.ZooKeeper - Client environment:user.dir=/root/apache-shardingsphere-incubating-4.0.0-RC2-sharding-proxy-bin
[INFO ] 09:54:56.864 [main] org.apache.zookeeper.ZooKeeper - Initiating client connection, connectString=localhost:2181 sessionTimeout=60000 watcher=org.apache.curator.ConnectionState@67c33749
[INFO ] 09:54:56.874 [main-SendThread(localhost:2181)] org.apache.zookeeper.ClientCnxn - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
[INFO ] 09:54:56.904 [main-SendThread(localhost:2181)] org.apache.zookeeper.ClientCnxn - Socket connection established to localhost/127.0.0.1:2181, initiating session
[INFO ] 09:54:56.922 [main-SendThread(localhost:2181)] org.apache.zookeeper.ClientCnxn - Session establishment complete on server localhost/127.0.0.1:2181, sessionid = 0x16d18c861d00003, negotiated timeout = 40000
[INFO ] 09:54:56.924 [main-EventThread] o.a.c.f.state.ConnectionStateManager - State change: CONNECTED
[INFO ] 09:54:57.457 [Curator-Framework-0] o.a.c.f.imps.CuratorFrameworkImpl - backgroundOperationsLoop exiting
[INFO ] 09:54:57.466 [main] org.apache.zookeeper.ZooKeeper - Session: 0x16d18c861d00003 closed
[INFO ] 09:54:57.466 [main-EventThread] org.apache.zookeeper.ClientCnxn - EventThread shut down for session: 0x16d18c861d00003
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.core.yaml.engine.YamlEngine.unmarshal(YamlEngine.java:87)
	at org.apache.shardingsphere.orchestration.internal.registry.config.service.ConfigurationService.loadAuthentication(ConfigurationService.java:244)
	at org.apache.shardingsphere.shardingproxy.Bootstrap.startWithRegistryCenter(Bootstrap.java:110)
	at org.apache.shardingsphere.shardingproxy.Bootstrap.main(Bootstrap.java:80)

Does anyone know how to solve this problem?


Changed files:
sharding-proxy/sharding-proxy-bootstrap/src/main/java/org/apache/shardingsphere/shardingproxy/Bootstrap.java

diff --git a/sharding-proxy/sharding-proxy-bootstrap/src/main/java/org/apache/shardingsphere/shardingproxy/Bootstrap.java b/sharding-proxy/sharding-proxy-bootstrap/src/main/java/org/apache/shardingsphere/shardingproxy/Bootstrap.java
index 5e9b767ddfd..9b60f4813c6 100644
--- a/sharding-proxy/sharding-proxy-bootstrap/src/main/java/org/apache/shardingsphere/shardingproxy/Bootstrap.java
+++ b/sharding-proxy/sharding-proxy-bootstrap/src/main/java/org/apache/shardingsphere/shardingproxy/Bootstrap.java
@@ -109,11 +109,11 @@ public final class Bootstrap {
                                                 final Collection<String> shardingSchemaNames, final Map<String, YamlProxyRuleConfiguration> ruleConfigs, final int port) {
         try (ShardingOrchestrationFacade shardingOrchestrationFacade = new ShardingOrchestrationFacade(
                 new OrchestrationConfigurationYamlSwapper().swap(serverConfig.getOrchestration()), shardingSchemaNames)) {
+            initShardingOrchestrationFacade(serverConfig, ruleConfigs, shardingOrchestrationFacade);
             Authentication authentication = shardingOrchestrationFacade.getConfigService().loadAuthentication();
             Properties properties = shardingOrchestrationFacade.getConfigService().loadProperties();
             ConfigurationLogger.log(authentication);
             ConfigurationLogger.log(properties);
-            initShardingOrchestrationFacade(serverConfig, ruleConfigs, shardingOrchestrationFacade);
             ShardingProxyContext.getInstance().init(authentication, properties);
             LogicSchemas.getInstance().init(shardingSchemaNames, getSchemaDataSourceParameterMap(shardingOrchestrationFacade), getSchemaRules(shardingOrchestrationFacade), true);
             initOpenTracing();