Spring Cloud ZooKeeper集成Feign的坑2,服务调用了一次后第二次调用就变成了500,错误:Servlet.service() for servlet [dispatcherSe

Posted Jim

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Spring Cloud ZooKeeper集成Feign的坑2,服务调用了一次后第二次调用就变成了500,错误:Servlet.service() for servlet [dispatcherSe相关的知识,希望对你有一定的参考价值。

错误如下:

2017-09-19 15:05:24.659  INFO 9986 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.spring[email protected]56528192: startup date [Tue Sep 19 15:05:24 CST 2017]; root of context hierarchy
2017-09-19 15:05:24.858  INFO 9986 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 ‘javax.inject.Inject‘ annotation found and supported for autowiring
2017-09-19 15:05:24.892  INFO 9986 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean ‘configurationPropertiesRebinderAutoConfiguration‘ of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$574c2f6c] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

  .   ____          _            __ _ _
 /\\ / ___‘_ __ _ _(_)_ __  __ _ \ \ \ ( ( )\___ | ‘_ | ‘_| | ‘_ \/ _` | \ \ \  \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  ‘  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.5.7.RELEASE)

2017-09-19 15:05:25.100  INFO 9986 --- [           main] c.j.t.test.SampleZookeeperApplication    : No active profile set, falling back to default profiles: default
2017-09-19 15:05:25.109  INFO 9986 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot[email protected]3adcc812: startup date [Tue Sep 19 15:05:25 CST 2017]; parent: org.spring[email protected]56528192
2017-09-19 15:05:25.491  INFO 9986 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=95f3ba5c-e0d1-3851-8586-45eb4a5d5e3f
2017-09-19 15:05:25.505  INFO 9986 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 ‘javax.inject.Inject‘ annotation found and supported for autowiring
2017-09-19 15:05:25.522  INFO 9986 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean ‘com.jsoft.testspringboot.test.SampleZookeeperApplication$AppClient‘ of type [org.springframework.cloud.netflix.feign.FeignClientFactoryBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-09-19 15:05:25.544  INFO 9986 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean ‘org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration‘ of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$574c2f6c] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-09-19 15:05:25.808  INFO 9986 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2017-09-19 15:05:25.817  INFO 9986 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2017-09-19 15:05:25.818  INFO 9986 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.20
2017-09-19 15:05:25.893  INFO 9986 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2017-09-19 15:05:25.893  INFO 9986 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 784 ms
2017-09-19 15:05:25.969  INFO 9986 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: ‘dispatcherServlet‘ to [/]
2017-09-19 15:05:25.972  INFO 9986 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: ‘characterEncodingFilter‘ to: [/*]
2017-09-19 15:05:25.972  INFO 9986 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: ‘hiddenHttpMethodFilter‘ to: [/*]
2017-09-19 15:05:25.972  INFO 9986 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: ‘httpPutFormContentFilter‘ to: [/*]
2017-09-19 15:05:25.972  INFO 9986 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: ‘requestContextFilter‘ to: [/*]
2017-09-19 15:05:26.044  WARN 9986 --- [           main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.zookeeper.ZookeeperProperties contains validation constraints but had not been annotated with @Validated.
2017-09-19 15:05:26.045  WARN 9986 --- [           main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.zookeeper.ZookeeperProperties contains validation constraints but had not been annotated with @Validated.
2017-09-19 15:05:26.045  WARN 9986 --- [           main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.zookeeper.ZookeeperProperties contains validation constraints but had not been annotated with @Validated.
2017-09-19 15:05:26.093  INFO 9986 --- [           main] o.a.c.f.imps.CuratorFrameworkImpl        : Starting
2017-09-19 15:05:26.098  INFO 9986 --- [           main] org.apache.zookeeper.ZooKeeper           : Client environment:zookeeper.version=3.4.6-1569965, built on 02/20/2014 09:09 GMT
2017-09-19 15:05:26.098  INFO 9986 --- [           main] org.apache.zookeeper.ZooKeeper           : Client environment:host.name=jim-ubuntu-pc
2017-09-19 15:05:26.098  INFO 9986 --- [           main] org.apache.zookeeper.ZooKeeper           : Client environment:java.version=1.8.0_144
2017-09-19 15:05:26.098  INFO 9986 --- [           main] org.apache.zookeeper.ZooKeeper           : Client environment:java.vendor=Oracle Corporation
2017-09-19 15:05:26.098  INFO 9986 --- [           main] org.apache.zookeeper.ZooKeeper           : Client environment:java.home=/usr/lib/jvm/java-8-oracle/jre
2017-09-19 15:05:26.098  INFO 9986 --- [           main] org.apache.zookeeper.ZooKeeper           : Client environment:java.class.path=/home/jim/eclipse-workspace/test/target/classes:/home/jim/.m2/repository/org/springframework/cloud/spring-cloud-starter-zookeeper-discovery/1.0.4.RELEASE/spring-cloud-starter-zookeeper-discovery-1.0.4.RELEASE.jar:/home/jim/.m2/repository/org/springframework/cloud/spring-cloud-starter-zookeeper/1.0.4.RELEASE/spring-cloud-starter-zookeeper-1.0.4.RELEASE.jar:/home/jim/.m2/repository/org/springframework/cloud/spring-cloud-zookeeper-core/1.0.4.RELEASE/spring-cloud-zookeeper-core-1.0.4.RELEASE.jar:/home/jim/.m2/repository/org/springframework/cloud/spring-cloud-zookeeper-discovery/1.0.4.RELEASE/spring-cloud-zookeeper-discovery-1.0.4.RELEASE.jar:/home/jim/.m2/repository/org/apache/curator/curator-x-discovery/2.10.0/curator-x-discovery-2.10.0.jar:/home/jim/.m2/repository/org/apache/curator/curator-recipes/2.10.0/curator-recipes-2.10.0.jar:/home/jim/.m2/repository/org/apache/curator/curator-framework/2.10.0/curator-framework-2.10.0.jar:/home/jim/.m2/repository/org/apache/curator/curator-client/2.10.0/curator-client-2.10.0.jar:/home/jim/.m2/repository/org/apache/zookeeper/zookeeper/3.4.6/zookeeper-3.4.6.jar:/home/jim/.m2/repository/jline/jline/0.9.94/jline-0.9.94.jar:/home/jim/.m2/repository/org/codehaus/jackson/jackson-mapper-asl/1.9.13/jackson-mapper-asl-1.9.13.jar:/home/jim/.m2/repository/org/codehaus/jackson/jackson-core-asl/1.9.13/jackson-core-asl-1.9.13.jar:/home/jim/.m2/repository/org/springframework/cloud/spring-cloud-netflix-core/1.2.7.RELEASE/spring-cloud-netflix-core-1.2.7.RELEASE.jar:/home/jim/.m2/repository/org/springframework/boot/spring-boot/1.5.7.RELEASE/spring-boot-1.5.7.RELEASE.jar:/home/jim/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/1.5.7.RELEASE/spring-boot-autoconfigure-1.5.7.RELEASE.jar:/home/jim/.m2/repository/org/springframework/cloud/spring-cloud-starter-archaius/1.2.7.RELEASE/spring-cloud-starter-archaius-1.2.7.RELEASE.jar:/home/jim/.m2/repository/com/netflix/archaius/archaius-core/0.7.4/archaius-core-0.7.4.jar:/home/jim/.m2/repository/com/google/code/findbugs/jsr305/3.0.1/jsr305-3.0.1.jar:/home/jim/.m2/repository/commons-configuration/commons-configuration/1.8/commons-configuration-1.8.jar:/home/jim/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.8.0/jackson-annotations-2.8.0.jar:/home/jim/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.8.10/jackson-core-2.8.10.jar:/home/jim/.m2/repository/com/google/guava/guava/18.0/guava-18.0.jar:/home/jim/.m2/repository/com/netflix/ribbon/ribbon/2.2.0/ribbon-2.2.0.jar:/home/jim/.m2/repository/com/netflix/ribbon/ribbon-transport/2.2.0/ribbon-transport-2.2.0.jar:/home/jim/.m2/repository/io/reactivex/rxnetty-contexts/0.4.9/rxnetty-contexts-0.4.9.jar:/home/jim/.m2/repository/io/reactivex/rxnetty-servo/0.4.9/rxnetty-servo-0.4.9.jar:/home/jim/.m2/repository/com/netflix/hystrix/hystrix-core/1.5.6/hystrix-core-1.5.6.jar:/home/jim/.m2/repository/org/hdrhistogram/HdrHistogram/2.1.9/HdrHistogram-2.1.9.jar:/home/jim/.m2/repository/javax/inject/javax.inject/1/javax.inject-1.jar:/home/jim/.m2/repository/io/reactivex/rxjava/1.1.10/rxjava-1.1.10.jar:/home/jim/.m2/repository/io/reactivex/rxnetty/0.4.9/rxnetty-0.4.9.jar:/home/jim/.m2/repository/io/netty/netty-codec-http/4.0.27.Final/netty-codec-http-4.0.27.Final.jar:/home/jim/.m2/repository/io/netty/netty-codec/4.0.27.Final/netty-codec-4.0.27.Final.jar:/home/jim/.m2/repository/io/netty/netty-handler/4.0.27.Final/netty-handler-4.0.27.Final.jar:/home/jim/.m2/repository/io/netty/netty-transport-native-epoll/4.0.27.Final/netty-transport-native-epoll-4.0.27.Final.jar:/home/jim/.m2/repository/io/netty/netty-common/4.0.27.Final/netty-common-4.0.27.Final.jar:/home/jim/.m2/repository/io/netty/netty-buffer/4.0.27.Final/netty-buffer-4.0.27.Final.jar:/home/jim/.m2/repository/io/netty/netty-transport/4.0.27.Final/netty-transport-4.0.27.Final.jar:/home/jim/.m2/repository/com/netflix/ribbon/ribbon-core/2.2.0/ribbon-core-2.2.0.jar:/home/jim/.m2/repository/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar:/home/jim/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar:/home/jim/.m2/repository/com/netflix/ribbon/ribbon-httpclient/2.2.0/ribbon-httpclient-2.2.0.jar:/home/jim/.m2/repository/commons-collections/commons-collections/3.2.2/commons-collections-3.2.2.jar:/home/jim/.m2/repository/org/apache/httpcomponents/httpclient/4.5.3/httpclient-4.5.3.jar:/home/jim/.m2/repository/org/apache/httpcomponents/httpcore/4.4.6/httpcore-4.4.6.jar:/home/jim/.m2/repository/commons-codec/commons-codec/1.10/commons-codec-1.10.jar:/home/jim/.m2/repository/com/sun/jersey/jersey-client/1.19.1/jersey-client-1.19.1.jar:/home/jim/.m2/repository/com/sun/jersey/jersey-core/1.19.1/jersey-core-1.19.1.jar:/home/jim/.m2/repository/javax/ws/rs/jsr311-api/1.1.1/jsr311-api-1.1.1.jar:/home/jim/.m2/repository/com/sun/jersey/contribs/jersey-apache-client4/1.19.1/jersey-apache-client4-1.19.1.jar:/home/jim/.m2/repository/com/netflix/servo/servo-core/0.10.1/servo-core-0.10.1.jar:/home/jim/.m2/repository/com/netflix/servo/servo-internal/0.10.1/servo-internal-0.10.1.jar:/home/jim/.m2/repository/com/netflix/netflix-commons/netflix-commons-util/0.1.1/netflix-commons-util-0.1.1.jar:/home/jim/.m2/repository/com/netflix/ribbon/ribbon-loadbalancer/2.2.0/ribbon-loadbalancer-2.2.0.jar:/home/jim/.m2/repository/com/netflix/netflix-commons/netflix-statistics/0.1.1/netflix-statistics-0.1.1.jar:/home/jim/.m2/repository/org/springframework/boot/spring-boot-starter-web/1.5.7.RELEASE/spring-boot-starter-web-1.5.7.RELEASE.jar:/home/jim/.m2/repository/org/springframework/boot/spring-boot-starter/1.5.7.RELEASE/spring-boot-starter-1.5.7.RELEASE.jar:/home/jim/.m2/repository/org/springframework/boot/spring-boot-starter-logging/1.5.7.RELEASE/spring-boot-starter-logging-1.5.7.RELEASE.jar:/home/jim/.m2/repository/ch/qos/logback/logback-classic/1.1.11/logback-classic-1.1.11.jar:/home/jim/.m2/repository/ch/qos/logback/logback-core/1.1.11/logback-core-1.1.11.jar:/home/jim/.m2/repository/org/slf4j/jcl-over-slf4j/1.7.25/jcl-over-slf4j-1.7.25.jar:/home/jim/.m2/repository/org/slf4j/jul-to-slf4j/1.7.25/jul-to-slf4j-1.7.25.jar:/home/jim/.m2/repository/org/slf4j/log4j-over-slf4j/1.7.25/log4j-over-slf4j-1.7.25.jar:/home/jim/.m2/repository/org/springframework/spring-core/4.3.11.RELEASE/spring-core-4.3.11.RELEASE.jar:/home/jim/.m2/repository/org/yaml/snakeyaml/1.17/snakeyaml-1.17.jar:/home/jim/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/1.5.7.RELEASE/spring-boot-starter-tomcat-1.5.7.RELEASE.jar:/home/jim/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/8.5.20/tomcat-embed-core-8.5.20.jar:/home/jim/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/8.5.20/tomcat-embed-el-8.5.20.jar:/home/jim/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/8.5.20/tomcat-embed-websocket-8.5.20.jar:/home/jim/.m2/repository/org/hibernate/hibernate-validator/5.3.5.Final/hibernate-validator-5.3.5.Final.jar:/home/jim/.m2/repository/javax/validation/validation-api/1.1.0.Final/validation-api-1.1.0.Final.jar:/home/jim/.m2/repository/org/jboss/logging/jboss-logging/3.3.1.Final/jboss-logging-3.3.1.Final.jar:/home/jim/.m2/repository/com/fasterxml/classmate/1.3.4/classmate-1.3.4.jar:/home/jim/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.8.10/jackson-databind-2.8.10.jar:/home/jim/.m2/repository/org/springframework/spring-web/4.3.11.RELEASE/spring-web-4.3.11.RELEASE.jar:/home/jim/.m2/repository/org/springframework/spring-aop/4.3.11.RELEASE/spring-aop-4.3.11.RELEASE.jar:/home/jim/.m2/repository/org/springframework/spring-beans/4.3.11.RELEASE/spring-beans-4.3.11.RELEASE.jar:/home/jim/.m2/repository/org/springframework/spring-context/4.3.11.RELEASE/spring-context-4.3.11.RELEASE.jar:/home/jim/.m2/repository/org/springframework/spring-webmvc/4.3.11.RELEASE/spring-webmvc-4.3.11.RELEASE.jar:/home/jim/.m2/repository/org/springframework/spring-expression/4.3.11.RELEASE/spring-expression-4.3.11.RELEASE.jar:/home/jim/.m2/repository/org/springframework/cloud/spring-cloud-starter-feign/1.2.7.RELEASE/spring-cloud-starter-feign-1.2.7.RELEASE.jar:/home/jim/.m2/repository/org/springframework/cloud/spring-cloud-starter/1.1.9.RELEASE/spring-cloud-starter-1.1.9.RELEASE.jar:/home/jim/.m2/repository/org/springframework/cloud/spring-cloud-context/1.1.9.RELEASE/spring-cloud-context-1.1.9.RELEASE.jar:/home/jim/.m2/repository/org/springframework/security/spring-security-rsa/1.0.3.RELEASE/spring-security-rsa-1.0.3.RELEASE.jar:/home/jim/.m2/repository/org/bouncycastle/bcpkix-jdk15on/1.55/bcpkix-jdk15on-1.55.jar:/home/jim/.m2/repository/org/bouncycastle/bcprov-jdk15on/1.55/bcprov-jdk15on-1.55.jar:/home/jim/.m2/repository/org/springframework/cloud/spring-cloud-commons/1.1.9.RELEASE/spring-cloud-commons-1.1.9.RELEASE.jar:/home/jim/.m2/repository/org/springframework/security/spring-security-crypto/4.2.3.RELEASE/spring-security-crypto-4.2.3.RELEASE.jar:/home/jim/.m2/repository/io/github/openfeign/feign-core/9.3.1/feign-core-9.3.1.jar:/home/jim/.m2/repository/org/jvnet/animal-sniffer-annotation/1.0/animal-sniffer-annotation-1.0.jar:/home/jim/.m2/repository/io/github/openfeign/feign-slf4j/9.3.1/feign-slf4j-9.3.1.jar:/home/jim/.m2/repository/io/github/openfeign/feign-hystrix/9.3.1/feign-hystrix-9.3.1.jar:/home/jim/.m2/repository/org/springframework/cloud/spring-cloud-starter-ribbon/1.2.7.RELEASE/spring-cloud-starter-ribbon-1.2.7.RELEASE.jar
2017-09-19 15:05:26.098  INFO 9986 --- [           main] org.apache.zookeeper.ZooKeeper           : Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2017-09-19 15:05:26.098  INFO 9986 --- [           main] org.apache.zookeeper.ZooKeeper           : Client environment:java.io.tmpdir=/tmp
2017-09-19 15:05:26.098  INFO 9986 --- [           main] org.apache.zookeeper.ZooKeeper           : Client environment:java.compiler=<NA>
2017-09-19 15:05:26.098  INFO 9986 --- [           main] org.apache.zookeeper.ZooKeeper           : Client environment:os.name=Linux
2017-09-19 15:05:26.098  INFO 9986 --- [           main] org.apache.zookeeper.ZooKeeper           : Client environment:os.arch=amd64
2017-09-19 15:05:26.098  INFO 9986 --- [           main] org.apache.zookeeper.ZooKeeper           : Client environment:os.version=4.7.0.intel.r5.0
2017-09-19 15:05:26.098  INFO 9986 --- [           main] org.apache.zookeeper.ZooKeeper           : Client environment:user.name=jim
2017-09-19 15:05:26.098  INFO 9986 --- [           main] org.apache.zookeeper.ZooKeeper           : Client environment:user.home=/home/jim
2017-09-19 15:05:26.098  INFO 9986 --- [           main] org.apache.zookeeper.ZooKeeper           : Client environment:user.dir=/home/jim/eclipse-workspace/test
2017-09-19 15:05:26.099  INFO 9986 --- [           main] org.apache.zookeeper.ZooKeeper           : Initiating client connection, connectString=localhost:2181 sessionTimeout=60000 [email protected]
2017-09-19 15:05:26.110  INFO 9986 --- [localhost:2181)] org.apache.zookeeper.ClientCnxn          : Opening socket connection to server ip6-localhost/0:0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (unknown error)
2017-09-19 15:05:26.113  INFO 9986 --- [localhost:2181)] org.apache.zookeeper.ClientCnxn          : Socket connection established to ip6-localhost/0:0:0:0:0:0:0:1:2181, initiating session
2017-09-19 15:05:26.138  INFO 9986 --- [localhost:2181)] org.apache.zookeeper.ClientCnxn          : Session establishment complete on server ip6-localhost/0:0:0:0:0:0:0:1:2181, sessionid = 0x15e98c6d1b30005, negotiated timeout = 40000
2017-09-19 15:05:26.148  INFO 9986 --- [ain-EventThread] o.a.c.f.state.ConnectionStateManager     : State change: CONNECTED
2017-09-19 15:05:26.320  INFO 9986 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.spring[email protected]1cb37ee4: startup date [Tue Sep 19 15:05:26 CST 2017]; parent: org.springframework.boot[email protected]3adcc812
2017-09-19 15:05:26.333  INFO 9986 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 ‘javax.inject.Inject‘ annotation found and supported for autowiring
2017-09-19 15:05:26.580  INFO 9986 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot[email protected]3adcc812: startup date [Tue Sep 19 15:05:25 CST 2017]; parent: org.spring[email protected]56528192
2017-09-19 15:05:26.621  INFO 9986 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/]}" onto public org.springframework.cloud.client.ServiceInstance com.jsoft.testspringboot.test.SampleZookeeperApplication.lb()
2017-09-19 15:05:26.622  INFO 9986 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/myenv]}" onto public java.lang.String com.jsoft.testspringboot.test.SampleZookeeperApplication.env(java.lang.String)
2017-09-19 15:05:26.622  INFO 9986 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/hi]}" onto public java.lang.String com.jsoft.testspringboot.test.SampleZookeeperApplication.hi()
2017-09-19 15:05:26.622  INFO 9986 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/self]}" onto public java.lang.String com.jsoft.testspringboot.test.SampleZookeeperApplication.self()
2017-09-19 15:05:26.624  INFO 9986 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2017-09-19 15:05:26.624  INFO 9986 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2017-09-19 15:05:26.661  INFO 9986 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-09-19 15:05:26.661  INFO 9986 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-09-19 15:05:26.686  INFO 9986 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-09-19 15:05:26.781  WARN 9986 --- [           main] o.s.c.n.a.ArchaiusAutoConfiguration      : No spring.application.name found, defaulting to ‘application‘
2017-09-19 15:05:26.784  WARN 9986 --- [           main] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
2017-09-19 15:05:26.784  INFO 9986 --- [           main] c.n.c.sources.URLConfigurationSource     : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2017-09-19 15:05:26.788  WARN 9986 --- [           main] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
2017-09-19 15:05:26.788  INFO 9986 --- [           main] c.n.c.sources.URLConfigurationSource     : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2017-09-19 15:05:26.829  INFO 9986 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2017-09-19 15:05:26.834  INFO 9986 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name ‘configurationPropertiesRebinder‘ has been autodetected for JMX exposure
2017-09-19 15:05:26.835  INFO 9986 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name ‘environmentManager‘ has been autodetected for JMX exposure
2017-09-19 15:05:26.835  INFO 9986 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name ‘refreshScope‘ has been autodetected for JMX exposure
2017-09-19 15:05:26.838  INFO 9986 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Located managed bean ‘environmentManager‘: registering with JMX server as MBean [org.springframework.cloud.context.environment:name=environmentManager,type=EnvironmentManager]
2017-09-19 15:05:26.848  INFO 9986 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Located managed bean ‘refreshScope‘: registering with JMX server as MBean [org.springframework.cloud.context.scope.refresh:name=refreshScope,type=RefreshScope]
2017-09-19 15:05:26.854  INFO 9986 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Located managed bean ‘configurationPropertiesRebinder‘: registering with JMX server as MBean [org.springframework.cloud.context.properties:name=configurationPropertiesRebinder,context=3adcc812,type=ConfigurationPropertiesRebinder]
2017-09-19 15:05:26.888  WARN 9986 --- [           main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.zookeeper.ZookeeperProperties contains validation constraints but had not been annotated with @Validated.
2017-09-19 15:05:26.889  WARN 9986 --- [           main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.zookeeper.ZookeeperProperties contains validation constraints but had not been annotated with @Validated.
2017-09-19 15:05:26.889  WARN 9986 --- [           main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.zookeeper.ZookeeperProperties contains validation constraints but had not been annotated with @Validated.
2017-09-19 15:05:26.892  WARN 9986 --- [           main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.zookeeper.ZookeeperProperties contains validation constraints but had not been annotated with @Validated.
2017-09-19 15:05:26.892  WARN 9986 --- [           main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.zookeeper.ZookeeperProperties contains validation constraints but had not been annotated with @Validated.
2017-09-19 15:05:26.892  WARN 9986 --- [           main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.zookeeper.ZookeeperProperties contains validation constraints but had not been annotated with @Validated.
2017-09-19 15:05:26.907  INFO 9986 --- [           main] o.s.c.support.DefaultLifecycleProcessor  : Starting beans in phase 0
2017-09-19 15:05:26.937  INFO 9986 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2017-09-19 15:05:27.078  INFO 9986 --- [           main] c.j.t.test.SampleZookeeperApplication    : Started SampleZookeeperApplication in 2.669 seconds (JVM running for 2.875)
2017-09-19 15:05:32.533  INFO 9986 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring FrameworkServlet ‘dispatcherServlet‘
2017-09-19 15:05:32.533  INFO 9986 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet ‘dispatcherServlet‘: initialization started
2017-09-19 15:05:32.540  INFO 9986 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet ‘dispatcherServlet‘: initialization completed in 7 ms
2017-09-19 15:05:32.653  INFO 9986 --- [tZookeeperApp-1] s.c.a.AnnotationConfigApplicationContext : Refreshing org.spring[email protected]b18c7ff: startup date [Tue Sep 19 15:05:32 CST 2017]; parent: org.springframework.boot[email protected]3adcc812
2017-09-19 15:05:32.697  INFO 9986 --- [tZookeeperApp-1] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 ‘javax.inject.Inject‘ annotation found and supported for autowiring
2017-09-19 15:05:32.792  INFO 9986 --- [tZookeeperApp-1] c.netflix.config.ChainedDynamicProperty  : Flipping property: testZookeeperApp.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit = 2147483647
2017-09-19 15:05:32.804  INFO 9986 --- [tZookeeperApp-1] c.n.u.concurrent.ShutdownEnabledTimer    : Shutdown hook installed for: NFLoadBalancer-PingTimer-testZookeeperApp
2017-09-19 15:05:32.812  INFO 9986 --- [tZookeeperApp-1] c.netflix.loadbalancer.BaseLoadBalancer  : Client:testZookeeperApp instantiated a LoadBalancer:DynamicServerListLoadBalancer:{NFLoadBalancer:name=testZookeeperApp,current list of Servers=[],Load balancer stats=Zone stats: {},Server stats: []}ServerList:null
2017-09-19 15:05:32.816  INFO 9986 --- [tZookeeperApp-1] c.n.l.DynamicServerListLoadBalancer      : Using serverListUpdater PollingServerListUpdater
2017-09-19 15:05:32.818  INFO 9986 --- [tZookeeperApp-1] c.n.l.DynamicServerListLoadBalancer      : DynamicServerListLoadBalancer for client testZookeeperApp initialized: DynamicServerListLoadBalancer:{NFLoadBalancer:name=testZookeeperApp,current list of Servers=[],Load balancer stats=Zone stats: {},Server stats: []}ServerList:or[email protected]2d1cae1d
2017-09-19 15:05:33.042 ERROR 9986 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is com.netflix.hystrix.exception.HystrixRuntimeException: AppClient#hi() failed and no fallback available.] with root cause

com.netflix.client.ClientException: Load balancer does not have available server for client: testZookeeperApp
    at com.netflix.loadbalancer.LoadBalancerContext.getServerFromLoadBalancer(LoadBalancerContext.java:468) ~[ribbon-loadbalancer-2.2.0.jar:2.2.0]
    at com.netflix.loadbalancer.reactive.LoadBalancerCommand$1.call(LoadBalancerCommand.java:184) ~[ribbon-loadbalancer-2.2.0.jar:2.2.0]
    at com.netflix.loadbalancer.reactive.LoadBalancerCommand$1.call(LoadBalancerCommand.java:180) ~[ribbon-loadbalancer-2.2.0.jar:2.2.0]
    at rx.Observable.unsafeSubscribe(Observable.java:10211) ~[rxjava-1.1.10.jar:1.1.10]
    at rx.internal.operators.OnSubscribeConcatMap.call(OnSubscribeConcatMap.java:94) ~[rxjava-1.1.10.jar:1.1.10]
    at rx.internal.operators.OnSubscribeConcatMap.call(OnSubscribeConcatMap.java:42) ~[rxjava-1.1.10.jar:1.1.10]
    at rx.Observable.unsafeSubscribe(Observable.java:10211) ~[rxjava-1.1.10.jar:1.1.10]
    at rx.internal.operators.OperatorRetryWithPredicate$SourceSubscriber$1.call(OperatorRetryWithPredicate.java:127) ~[rxjava-1.1.10.jar:1.1.10]
    at rx.internal.schedulers.TrampolineScheduler$InnerCurrentThreadScheduler.enqueue(TrampolineScheduler.java:73) ~[rxjava-1.1.10.jar:1.1.10]
    at rx.internal.schedulers.TrampolineScheduler$InnerCurrentThreadScheduler.schedule(TrampolineScheduler.java:52) ~[rxjava-1.1.10.jar:1.1.10]
    at rx.internal.operators.OperatorRetryWithPredicate$SourceSubscriber.onNext(OperatorRetryWithPredicate.java:79) ~[rxjava-1.1.10.jar:1.1.10]
    at rx.internal.operators.OperatorRetryWithPredicate$SourceSubscriber.onNext(OperatorRetryWithPredicate.java:45) ~[rxjava-1.1.10.jar:1.1.10]
    at rx.internal.util.ScalarSynchronousObservable$WeakSingleProducer.request(ScalarSynchronousObservable.java:276) ~[rxjava-1.1.10.jar:1.1.10]
    at rx.Subscriber.setProducer(Subscriber.java:209) ~[rxjava-1.1.10.jar:1.1.10]
    at rx.internal.util.ScalarSynchronousObservable$JustOnSubscribe.call(ScalarSynchronousObservable.java:138) ~[rxjava-1.1.10.jar:1.1.10]
    at rx.internal.util.ScalarSynchronousObservable$JustOnSubscribe.call(ScalarSynchronousObservable.java:129) ~[rxjava-1.1.10.jar:1.1.10]
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) ~[rxjava-1.1.10.jar:1.1.10]
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[rxjava-1.1.10.jar:1.1.10]
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) ~[rxjava-1.1.10.jar:1.1.10]
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[rxjava-1.1.10.jar:1.1.10]
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) ~[rxjava-1.1.10.jar:1.1.10]
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[rxjava-1.1.10.jar:1.1.10]
    at rx.Observable.subscribe(Observable.java:10307) ~[rxjava-1.1.10.jar:1.1.10]
    at rx.Observable.subscribe(Observable.java:10274) ~[rxjava-1.1.10.jar:1.1.10]
    at rx.observables.BlockingObservable.blockForSingle(BlockingObservable.java:445) ~[rxjava-1.1.10.jar:1.1.10]
    at rx.observables.BlockingObservable.single(BlockingObservable.java:342) ~[rxjava-1.1.10.jar:1.1.10]
    at com.netflix.client.AbstractLoadBalancerAwareClient.executeWithLoadBalancer(AbstractLoadBalancerAwareClient.java:102) ~[ribbon-loadbalancer-2.2.0.jar:2.2.0]
    at org.springframework.cloud.netflix.feign.ribbon.LoadBalancerFeignClient.execute(LoadBalancerFeignClient.java:63) ~[spring-cloud-netflix-core-1.2.7.RELEASE.jar:1.2.7.RELEASE]
    at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:97) ~[feign-core-9.3.1.jar:na]
    at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:76) ~[feign-core-9.3.1.jar:na]
    at feign.hystrix.HystrixInvocationHandler$1.run(HystrixInvocationHandler.java:108) ~[feign-hystrix-9.3.1.jar:na]
    at com.netflix.hystrix.HystrixCommand$2.call(HystrixCommand.java:301) ~[hystrix-core-1.5.6.jar:1.5.6]
    at com.netflix.hystrix.HystrixCommand$2.call(HystrixCommand.java:297) ~[hystrix-core-1.5.6.jar:1.5.6]
    at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:46) ~[rxjava-1.1.10.jar:1.1.10]
    at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:35) ~[rxjava-1.1.10.jar:1.1.10]
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) ~[rxjava-1.1.10.jar:1.1.10]
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[rxjava-1.1.10.jar:1.1.10]
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) ~[rxjava-1.1.10.jar:1.1.10]
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[rxjava-1.1.10.jar:1.1.10]
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) ~[rxjava-1.1.10.jar:1.1.10]
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[rxjava-1.1.10.jar:1.1.10]
    at rx.Observable.unsafeSubscribe(Observable.java:10211) ~[rxjava-1.1.10.jar:1.1.10]
    at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:51) ~[rxjava-1.1.10.jar:1.1.10]
    at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:35) ~[rxjava-1.1.10.jar:1.1.10]
    at rx.Observable.unsafeSubscribe(Observable.java:10211) ~[rxjava-1.1.10.jar:1.1.10]
    at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:41) ~[rxjava-1.1.10.jar:1.1.10]
    at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:30) ~[rxjava-1.1.10.jar:1.1.10]
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) ~[rxjava-1.1.10.jar:1.1.10]
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[rxjava-1.1.10.jar:1.1.10]
    at rx.Observable.unsafeSubscribe(Observable.java:10211) ~[rxjava-1.1.10.jar:1.1.10]
    at rx.internal.operators.OperatorSubscribeOn$1.call(OperatorSubscribeOn.java:94) ~[rxjava-1.1.10.jar:1.1.10]
    at com.netflix.hystrix.strategy.concurrency.HystrixContexSchedulerAction$1.call(HystrixContexSchedulerAction.java:56) ~[hystrix-core-1.5.6.jar:1.5.6]
    at com.netflix.hystrix.strategy.concurrency.HystrixContexSchedulerAction$1.call(HystrixContexSchedulerAction.java:47) ~[hystrix-core-1.5.6.jar:1.5.6]
    at com.netflix.hystrix.strategy.concurrency.HystrixContexSchedulerAction.call(HystrixContexSchedulerAction.java:69) ~[hystrix-core-1.5.6.jar:1.5.6]
    at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55) ~[rxjava-1.1.10.jar:1.1.10]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[na:1.8.0_144]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_144]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_144]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_144]
    at java.lang.Thread.run(Thread.java:748) [na:1.8.0_144]

错误现象:

1、 服务调用了一次后第二次调用就变成了500

2、或者调用的服务直接出现500。错误同样是出现以上信息。

问题排查:

1、排查Spring Cloud的版本问题:Camden.SR7,与这个无关。

2、排查Feign的接口写法问题,也与这个无关。

3、排查引入的包少了,真的是这个问题。

4、排查配置问题的类型,peoperties与yaml,或者application.peoperties与bootstrap.properties,也与这个无关。

5、排查ZK的版本问题,同样也是无关。

6、排查连接到ZK的root路径和服务的名称和路径,同样也是无关。

7、排查在application.properties使用了spring.cloud.zookeeper.dependencies.,然后注释掉之后一切正常,无论在yaml还是bootstrap.yaml文件写的都同样的错误,问题发现就是这个问题。这个是业务需要使用,在应用名指定了用斜杠的名就必须使用这个属性指定,所以不能去掉。

问题说明:

1、关于spring.cloud.zookeeper.dependencies.

  • 引入org.springframework.cloud:spring-cloud-starter-zookeeper-discovery就可以自动配置Spring Cloud Zookeeper相关依赖;
  • 可以配置spring.cloud.zookeeper.dependencies来加入更多配置;
  • 可以设置spring.cloud.zookeeper.dependency.enabled为false,关闭自动依赖(默认true)
  • 为什么要用这个去指定,如果在指定spring.application.name时有路径斜杠,那么就必须使用这个做为别名来进行引入。

问题解决:

1、检查@FeignClient(value = "service-zookeeper")的写法,上面value如果有写spring.cloud.zookeeper.dependencies.service-zookeeper.path时,是指向这个,如果没有写就是服务的名称(spring.application.name=service-zookeeper)。

2、如果发现有上面的错误,那么第一时间先去配置文件上屏蔽spring.cloud.zookeeper.dependencies.进行排查。

3、真正解决本次的问题,在POM引入spring-boot-starter-actuator

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

说明:这个包是用做健康度监控的。

总结:

其实官方文档也是有坑的,可能从一开始发展到现在,文档有些遗漏导致一些包引入没说清除,甚至官方的示例代码上也没说明,导致上面的问题出现。

最终解决的方法就是去GitHub找使用了这个依赖关系的配置文件上的例子代码,最终才分析出结果。

 

参考:

https://my.oschina.net/roccn/blog/847350

http://www.jianshu.com/p/734519d3c383

以上是关于Spring Cloud ZooKeeper集成Feign的坑2,服务调用了一次后第二次调用就变成了500,错误:Servlet.service() for servlet [dispatcherSe的主要内容,如果未能解决你的问题,请参考以下文章

用Zookeeper作为Spring cloud的配置中心(转)

干货分享微服务spring-cloud(8.服务治理和配置中心Spring-cloud-zooke)

我爱java系列---springboot项目集成zookeeper作为注册中心

Spring Cloud Consul

为 spring-cloud-bus 设置 zookeeper 主机和端口

如何正确使用 Spring Cloud?下