springboot集成注册中心报错
来源:2-9 Springboot集成注册中心
zhangyulei
2018-10-21
集成后启动zk, 启动provider, 启动consumer时报错:
zk报错
2018-10-21 08:59:30,839 [myid:] - INFO [main:Environment@100] - Server environment:os.arch=amd64
2018-10-21 08:59:30,839 [myid:] - INFO [main:Environment@100] - Server environment:os.version=10.0
2018-10-21 08:59:30,839 [myid:] - INFO [main:Environment@100] - Server environment:user.name=Derek
2018-10-21 08:59:30,839 [myid:] - INFO [main:Environment@100] - Server environment:user.home=C:\Users\Administrator
2018-10-21 08:59:30,839 [myid:] - INFO [main:Environment@100] - Server environment:user.dir=E:\zookeeper\zookeeper-3.4.10\bin
2018-10-21 08:59:30,969 [myid:] - INFO [main:ZooKeeperServer@829] - tickTime set to 2000
2018-10-21 08:59:30,969 [myid:] - INFO [main:ZooKeeperServer@838] - minSessionTimeout set to -1
2018-10-21 08:59:30,969 [myid:] - INFO [main:ZooKeeperServer@847] - maxSessionTimeout set to -1
2018-10-21 08:59:39,795 [myid:] - INFO [main:NIOServerCnxnFactory@89] - binding to port 0.0.0.0/0.0.0.0:2181
2018-10-21 09:00:12,011 [myid:] - INFO [SessionTracker:ZooKeeperServer@358] - Expiring session 0x166923fcf53000a, timeout of 30000ms exceeded
2018-10-21 09:00:12,022 [myid:] - INFO [ProcessThread(sid:0 cport:2181)::PrepRequestProcessor@486] - Processed session termination for sessionid: 0x166923fcf53000a
2018-10-21 09:00:12,030 [myid:] - INFO [SyncThread:0:FileTxnLog@203] - Creating new log file: log.41
2018-10-21 09:04:44,112 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@192] - Accepted socket connection from /0:0:0:0:0:0:0:1:51452
2018-10-21 09:04:44,156 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@942] - Client attempting to establish new session at /0:0:0:0:0:0:0:1:51452
2018-10-21 09:04:44,255 [myid:] - INFO [SyncThread:0:ZooKeeperServer@687] - Established session 0x16694227d2d0000 with negotiated timeout 30000 for client /0:0:0:0:0:0:0:1:51452
2018-10-21 09:04:44,395 [myid:] - INFO [ProcessThread(sid:0 cport:2181)::PrepRequestProcessor@648] - Got user-level KeeperException when processing sessionid:0x16694227d2d0000 type:
:create cxid:0x4 zxid:0x44 txntype:-1 reqpath:n/a Error Path:/dubbo/com.derek.dubbo.provider.ServiceAPI/configurators Error:KeeperErrorCode = NodeExists for /dubbo/com.derek.dubbo.provider.ServiceAPI/configurators
2018-10-21 09:07:13,128 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@192] - Accepted socket connection from /127.0.0.1:52576
2018-10-21 09:07:13,132 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@942] - Client attempting to establish new session at /127.0.0.1:52576
2018-10-21 09:07:13,209 [myid:] - INFO [SyncThread:0:ZooKeeperServer@687] - Established session 0x16694227d2d0001 with negotiated timeout 30000 for client /127.0.0.1:52576
2018-10-21 09:07:13,313 [myid:] - INFO [ProcessThread(sid:0 cport:2181)::PrepRequestProcessor@648] - Got user-level KeeperException when processing sessionid:0x16694227d2d0001 type:create cxid:0x4 zxid:0x47 txntype:-1 reqpath:n/a Error Path:/dubbo/com.derek.dubbo.consumer.ServiceAPI/providers Error:KeeperErrorCode = NodeExists for /dubbo/com.derek.dubbo.consumer.ServiceAPI/providers
2018-10-21 09:07:13,365 [myid:] - INFO [ProcessThread(sid:0 cport:2181)::PrepRequestProcessor@648] - Got user-level KeeperException when processing sessionid:0x16694227d2d0001 type:create cxid:0x8 zxid:0x48 txntype:-1 reqpath:n/a Error Path:/dubbo/com.derek.dubbo.consumer.ServiceAPI/configurators Error:KeeperErrorCode = NodeExists for /dubbo/com.derek.dubbo.consumer.ServiceAPI/configurators
2018-10-21 09:07:13,415 [myid:] - INFO [ProcessThread(sid:0 cport:2181)::PrepRequestProcessor@648] - Got user-level KeeperException when processing sessionid:0x16694227d2d0001 type:create cxid:0xc zxid:0x49 txntype:-1 reqpath:n/a Error Path:/dubbo/com.derek.dubbo.consumer.ServiceAPI/routers Error:KeeperErrorCode = NodeExists for /dubbo/com.derek.dubbo.consumer.ServiceAPI/routers
2018-10-21 09:07:13,518 [myid:] - INFO [ProcessThread(sid:0 cport:2181)::PrepRequestProcessor@486] - Processed session termination for sessionid: 0x16694227d2d0001
2018-10-21 09:07:13,581 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@1044] - Closed socket connection for client /127.0.0.1:52576 which had sessionid 0x16694227d2d0001
2018-10-21 09:15:03,906 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@192] - Accepted socket connection from /127.0.0.1:54782
2018-10-21 09:15:03,911 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@942] - Client attempting to establish new session at /127.0.0.1:54782
2018-10-21 09:15:03,998 [myid:] - INFO [SyncThread:0:ZooKeeperServer@687] - Established session 0x16694227d2d0002 with negotiated timeout 30000 for client /127.0.0.1:54782
2018-10-21 09:15:04,448 [myid:] - INFO [ProcessThread(sid:0 cport:2181)::PrepRequestProcessor@486] - Processed session termination for sessionid: 0x16694227d2d0002
2018-10-21 09:15:04,511 [myid:] - WARN [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@368] - caught end of stream exception
EndOfStreamException: Unable to read additional data from client sessionid 0x16694227d2d0002, likely client has closed socket
at org.apache.zookeeper.server.NIOServerCnxn.doIO(NIOServerCnxn.java:239)
at org.apache.zookeeper.server.NIOServerCnxnFactory.run(NIOServerCnxnFactory.java:203)
at java.lang.Thread.run(Thread.java:748)
2018-10-21 09:15:04,514 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@1044] - Closed socket connection for client /127.0.0.1:54782 which had sessionid 0x16694227d2d0002
consumer端代码报错:
:: Dubbo :: (v2.6.0)
:: Spring Boot :: (v2.0.6.RELEASE)
2018-10-21 09:15:03.907 INFO 8732 --- [127.0.0.1:2181)] org.apache.zookeeper.ClientCnxn : Socket connection established to 127.0.0.1/127.0.0.1:2181, initiating session
2018-10-21 09:15:04.001 INFO 8732 --- [127.0.0.1:2181)] org.apache.zookeeper.ClientCnxn : Session establishment complete on server 127.0.0.1/127.0.0.1:2181, sessionid = 0x16694227d2d0002, negotiated timeout = 30000
2018-10-21 09:15:04.003 INFO 8732 --- [tor-EventThread] org.I0Itec.zkclient.ZkClient : zookeeper state changed (SyncConnected)
2018-10-21 09:15:04.395 WARN 8732 --- [ main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'consumer' defined in file [E:\IntelliJ IDEA\WorkSpace\dubbo\dubbo\consumer\target\classes\com\derek\dubbo\consumer\Consumer.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: consumer; nested exception is java.lang.IllegalStateException: Failed to check the status of the service com.derek.ServiceAPI. No provider available for the service com.derek.ServiceAPI from the url zookeeper://127.0.0.1:2181/com.alibaba.dubbo.registry.RegistryService?application=dubbo-spring-boot-consumer&dubbo=2.6.0&interface=com.derek.ServiceAPI&methods=sendMessate&pid=8732®ister.ip=192.168.242.1&side=consumer×tamp=1540084503797 to the consumer 192.168.242.1 use dubbo version 2.6.0
2018-10-21 09:15:04.412 INFO 8732 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-10-21 09:15:04.432 ERROR 8732 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'consumer' defined in file [E:\IntelliJ IDEA\WorkSpace\dubbo\dubbo\consumer\target\classes\com\derek\dubbo\consumer\Consumer.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: consumer; nested exception is java.lang.IllegalStateException: Failed to check the status of the service com.derek.ServiceAPI. No provider available for the service com.derek.ServiceAPI from the url zookeeper://127.0.0.1:2181/com.alibaba.dubbo.registry.RegistryService?application=dubbo-spring-boot-consumer&dubbo=2.6.0&interface=com.derek.ServiceAPI&methods=sendMessate&pid=8732®ister.ip=192.168.242.1&side=consumer×tamp=1540084503797 to the consumer 192.168.242.1 use dubbo version 2.6.0
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:581) ~[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495) ~[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:759) ~[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) ~[spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:548) ~[spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) [spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:386) [spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) [spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1242) [spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1230) [spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE]
at com.derek.dubbo.ConsumerApplication.main(ConsumerApplication.java:14) [classes/:na]
Caused by: org.springframework.beans.factory.BeanCreationException: consumer; nested exception is java.lang.IllegalStateException: Failed to check the status of the service com.derek.ServiceAPI. No provider available for the service com.derek.ServiceAPI from the url zookeeper://127.0.0.1:2181/com.alibaba.dubbo.registry.RegistryService?application=dubbo-spring-boot-consumer&dubbo=2.6.0&interface=com.derek.ServiceAPI&methods=sendMessate&pid=8732®ister.ip=192.168.242.1&side=consumer×tamp=1540084503797 to the consumer 192.168.242.1 use dubbo version 2.6.0
at com.alibaba.dubbo.spring.boot.DubboConsumerAutoConfiguration$1.postProcessBeforeInitialization(DubboConsumerAutoConfiguration.java:100) ~[dubbo-spring-boot-starter-2.0.0.jar:na]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:416) ~[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1686) ~[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:573) ~[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]
... 14 common frames omitted
Caused by: java.lang.IllegalStateException: Failed to check the status of the service com.derek.ServiceAPI. No provider available for the service com.derek.ServiceAPI from the url zookeeper://127.0.0.1:2181/com.alibaba.dubbo.registry.RegistryService?application=dubbo-spring-boot-consumer&dubbo=2.6.0&interface=com.derek.ServiceAPI&methods=sendMessate&pid=8732®ister.ip=192.168.242.1&side=consumer×tamp=1540084503797 to the consumer 192.168.242.1 use dubbo version 2.6.0
at com.alibaba.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:422) ~[dubbo-2.6.0.jar:2.6.0]
at com.alibaba.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:333) ~[dubbo-2.6.0.jar:2.6.0]
at com.alibaba.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:163) ~[dubbo-2.6.0.jar:2.6.0]
at com.alibaba.dubbo.config.spring.ReferenceBean.getObject(ReferenceBean.java:59) ~[dubbo-2.6.0.jar:2.6.0]
at com.alibaba.dubbo.spring.boot.DubboConsumerAutoConfiguration$1.postProcessBeforeInitialization(DubboConsumerAutoConfiguration.java:89) ~[dubbo-spring-boot-starter-2.0.0.jar:na]
... 17 common frames omitted
consumer端配置代码:
配置文件:
spring.application.name=dubbo-spring-boot-consumer
spring.dubbo.registry=zookeeper://127.0.0.1:2181
启动类:
@SpringBootApplication
@EnableDubboConfiguration
public class ConsumerApplication {
public static void main(String[] args) {
ConfigurableApplicationContext run = SpringApplication.run(ConsumerApplication.class, args);
Consumer consumer = (Consumer) run.getBean("consumer");
consumer.sendMessage("你好。。");
}
}
consumer类:
@Component
public class Consumer {
// @Reference(url = "dubbo://127.0.0.1:20880")
@Reference(interfaceClass = ServiceAPI.class)
private ServiceAPI api ;
public void sendMessage(String message){
String msg = api.sendMessate(message);
System.out.println(msg);
}
}
**maven依赖:**
<dependency>
<groupId>com.alibaba.spring.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.101tec</groupId>
<artifactId>zkclient</artifactId>
<version>0.10</version>
</dependency>
consumer目录结构:
provider端没有错误信息
写回答
1回答
-
zhangyulei
提问者
2018-10-21
琢磨了一晚上 解决了。。。。 ServiceAPI 的路径要保持一致 一致 。。。 一致。。 才能调用到。。
012018-10-22
相似问题