These are chat archives for spring-cloud/spring-cloud

14th
Feb 2018
ghoddg
@ghoddg
Feb 14 2018 05:28
Hi All
I am implementing the api cloud gateway using spring cloud gateway with gradle as build tool, below is the configuration I made

buildscript {
ext {
springBootVersion = "2.0.0.M7"
}

apply plugin: "io.spring.dependency-management"
apply plugin: "org.springframework.boot"

dependencies {
compile(
'org.springframework.boot:spring-boot-starter-web',
'org.springframework.boot:spring-boot-starter-tomcat',
'org.springframework.boot:spring-boot-starter-actuator',
'org.springframework.boot:spring-boot-starter-webflux',
'org.springframework.cloud:spring-cloud-starter-gateway',
'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
)

testCompile(
'org.springframework.boot:spring-boot-starter-test',
'org.springframework.cloud:spring-cloud-starter-netflix-eureka-server'
)

dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:Finchley.M5"
mavenBom 'org.springframework.cloud:spring-cloud-gateway:2.0.0.BUILD-SNAPSHOT'
}
}

but when I starting the gateway service, getting the error as

ServerList:org.springframework.cloud.netflix.ribbon.eureka.DomainExtractingServerList@2794a625
2018-02-14 10:51:44.789 ERROR 13660 --- [ctor-http-nio-4] .a.w.r.e.DefaultErrorWebExceptionHandler : Failed to handle request [GET http://localhost:8081/plato-api-gateway/health]

java.lang.ClassCastException: org.springframework.core.io.buffer.DefaultDataBufferFactory cannot be cast to org.springframework.core.io.buffer.NettyDataBufferFactory
at org.springframework.cloud.gateway.filter.NettyWriteResponseFilter.lambda$filter$0(NettyWriteResponseFilter.java:61) ~[spring-cloud-gateway-core-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT]
at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:44) ~[reactor-core-3.1.3.RELEASE.jar:3.1.3.RELEASE]
at reactor.core.publisher.Mono.subscribe(Mono.java:3006) ~[reactor-core-3.1.3.RELEASE.jar:3.1.3.RELEASE]
at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.drain(MonoIgnoreThen.java:167) ~[reactor-core-3.1.3.RELEASE.jar:3.1.3.RELEASE]
at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.ignoreDone(MonoIgnoreThen.java:185) ~[reactor-core-3.1.3.RELEASE.jar:3.1.3.RELEASE]
at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreInner.onComplete(MonoIgnoreThen.java:234) ~[reactor-core-3.1.3.RELEASE.jar:3.1.3.RELEASE]
at reactor.core.publisher.FluxPeek$PeekSubscriber.onComplete(FluxPeek.java:245) ~[reactor-core-3.1.3.RELEASE.jar:3.1.3.RELEASE]
at reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:130) ~[reactor-core-3.1.3.RELEASE.jar:3.1.3.RELEASE]
at reactor.core.publisher.FluxRetryPredicate$RetryPredicateSubscriber.onComplete(FluxRetryPredicate.java:107) ~[reactor-core-3.1.3.RELEASE.jar:3.1.3.RELEASE]
at reactor.core.publisher.MonoCreate$DefaultMonoSink.success(MonoCreate.java:140) ~[reactor-core-3.1.3.RELEASE.jar:3.1.3.RELEASE]
at reactor.ipc.netty.channel.PooledClientContextHandler.fireContextActive(PooledClientContextHandler.java:84) ~[reactor-netty-0.7.3.RELEASE.jar:0.7.3.RELEASE]
at reactor.ipc.netty.http.client.HttpClientOperations.onInboundNext(HttpClientOperations.java:551) ~[reactor-netty-0.7.3.RELEASE.jar:0.7.3.RELEASE]
at reactor.ipc.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:134) ~[reactor-netty-0.7.3.RELEASE.jar:0.7.3.RELEASE]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) ~[netty-transport-4.1.20.Final.jar:4.1.20.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) ~[netty-transport-4.1.20.Final.jar:4.1.20.Final]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) ~[netty-transport-4.1.20.Final.jar:4.1.20.Final]
at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:438) ~[netty-transport-4.1.20.Final.jar:4.1.20.Final]
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:310) ~[netty-codec-4.1.20.Final.jar:4.1.20.Final]
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:297) ~[netty-codec-4.1.20.Final.jar:4.1.20.Final]
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:413) ~[netty-codec-4.1.20.Final.jar:4.1.20.Final]
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:265) ~[netty-codec-4.1.20.Final.jar:4.1.20.Final]
at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:253) ~[netty-transport-4.1.20.Final.jar:4.1.20.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) ~[netty-transport-4.1.20.Final.jar:4.1.20.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) ~[netty-transport-4.1.

Please help
Jagmohan Sharma
@JagmohanSharma
Feb 14 2018 07:01

Also, just read the documentation on @RefreshScope. It's the same for all beans.

@dsyer actually to just confirm on this point. when we are getting datasource and jdbcTemplate beans from auto configuration then we can not apply @RefreshScope on bean definitions. so for getting them refreshed, do we need to put @RefreshScope on beans where we injecting them?

Or this will be achieved though DataSourceProperties which is a @ConfigurationProperties and get rebinded with new values on any cloud config environment changes?
Dave Syer
@dsyer
Feb 14 2018 07:16
Not sure I follow you.
If you create a bean definition for a DataSource you can mark it as @RefreshScope.
If you create a bean definition for a DataSource you can mark it as @RefreshScope.
@ghoddg you have snapshots of gateway but old milestone releases of everything else, so I expect that's the problem. If you need snapshots you have to go all in with snapshots at this point (Spring Boot 2.0 is not stable yet).
Jagmohan Sharma
@JagmohanSharma
Feb 14 2018 07:28

@dsyer Yes, I agree. But my point was when we provide such jdbc parameters to spring boot to configure data source bean for us

spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/test
spring.datasource.username=root
spring.datasource.password=admin

Then we can directly autowire jdbcTemplate in our code. So how will we make that jdbctemplate bean marked with @RefreshScope? Sorry if I am misplacing things here.

ghoddg
@ghoddg
Feb 14 2018 07:36
@dsyer , Can you please let me know the compatible version i should use? versions of (spring boot, spring-cloud-dependencies and spring-cloud-gateway)
to get the things work
Dave Syer
@dsyer
Feb 14 2018 08:22
Currently @JagmohanSharma you have to create the beans yourself if you want them in refresh scope
@ghoddg
$ curl start.spring.io/build.gradle -d bootVersion=2.0.0.BUILD-SNAPSHOT -d dependencies=cloud-commons
ghoddg
@ghoddg
Feb 14 2018 09:10
@dsyer This command gives me timepout. is there any other option to get the compatible versions?
Dave Syer
@dsyer
Feb 14 2018 09:15
curl start.spring.io/build.gradle -d bootVersion=2.0.0.BUILD-SNAPSHOT -d dependencies=cloud-starter
I mistyped the starter name. But you should not get a timeout.
You can also go to start.spring.io in a browser and generate a complete project
ghoddg
@ghoddg
Feb 14 2018 09:27
@dsyer Thanks..I created project through start.spring.io, and my service is getting started properly. But when i checked the health of it, it is giving below error
"error": "Internal Server Error",
"message": "org.springframework.core.io.buffer.DefaultDataBufferFactory cannot be cast to org.springframework.core.io.buffer.NettyDataBufferFactory"
same error getting
Dave Syer
@dsyer
Feb 14 2018 09:35
Stack trace?
I see it above.
Please format it properly next time
Is it the same stack trace?
You said it was a problem on startup before?
Can you put your code in github and link to it from a new issue in spring-cloud-gateway, please?
ghoddg
@ghoddg
Feb 14 2018 09:39
yes it is same stack trace
ghoddg
@ghoddg
Feb 14 2018 10:04
Do you have any working code with Spring Cloud Gateway which i can build, run and test?
Dave Syer
@dsyer
Feb 14 2018 11:12
Did you look in the project?
ghoddg
@ghoddg
Feb 14 2018 11:51
@dsyer which project?
@dsyer , @spencergibb ,
I got below link
spring-cloud/spring-cloud-gateway#145
whatever error mentioned in this bug, same error I am also getting
but it seems this issue is still open.
Dave Syer
@dsyer
Feb 14 2018 11:53
Seems like it. That's good right?
ghoddg
@ghoddg
Feb 14 2018 11:53
yes
i have updated my error details also on that link .
Dave Syer
@dsyer
Feb 14 2018 11:54
:thumbsup:
ghoddg
@ghoddg
Feb 14 2018 11:55
thankx Dave. I am just waiting for response on this issue. I really dont want to got for zuul-2 as i have decided to go with Spring Cloud Gateway
szisti
@szisti
Feb 14 2018 11:56
hi guys
I'm having issues with the cloud config server (1.4.2)
Whereby I explicitly set the server.encrypt.enabled to false in the configuration but it still tries to encrypt the passwords (works perfectly with 1.3.1 with the same configuration)
Dave Syer
@dsyer
Feb 14 2018 12:01
Do you have a simple sample app? Link to a project in github would be useful.
szisti
@szisti
Feb 14 2018 12:03
@dsyer it's just a blank could config server no functionality added to it
Dave Syer
@dsyer
Feb 14 2018 12:03
Should be easy for you to create a sample then?
szisti
@szisti
Feb 14 2018 12:03
I'll try to create something simple from it and put it on github later today and ping you with the address as soon as i have
@dsyer I think it works if the configuration is in bootstrap.yaml and not in the application.yaml
Dave Syer
@dsyer
Feb 14 2018 12:10
I guess that might be expected. Make us a sample and we can see.
Zhenyang Hua
@zhenyanghua
Feb 14 2018 13:31
What is the right way to break the yaml config line:
spring:
  profiles:
    active: native
  cloud:
    config:
      server:
        native:
          searchLocations: file:///C:/config/service1,file:///C:/config/service2,file:///C:/config/service3,file:///C:/config/service4,file:///C:/config/service5,file:///C:/config/service6
I tried the following and they don’t work:
searchLocations: 
file:///C:/config/service1,\
file:///C:/config/service2,\
file:///C:/config/service3,\
file:///C:/config/service4,\
file:///C:/config/service5,\
file:///C:/config/service6
szisti
@szisti
Feb 14 2018 13:54
@dsyer https://github.com/szisti/config-server I've tested it in this blank project, if I create an additional bootstrap file and move the encrypt enabled other there it works as expected
Dave Syer
@dsyer
Feb 14 2018 14:23
OK thanks
Zhenyang Hua
@zhenyanghua
Feb 14 2018 14:32
@dsyer Thanks! The block style works!
Tim Ysewyn
@TYsewyn
Feb 14 2018 14:49

Hi @spencergibb & @marcingrzejszczak, I got a question. Currently we have a pollable channel that we’re polling for a message every x ms.
We also have a Spring Cloud Sleuth interceptor configured, but he goes haywire whenever the queue is empty.
The poller returns null and that in turn creates a NullPointerException in TracingChannelInterceptor.

I’m not sure how to fix this in a PR:

  • Should the interceptor also track null messages, wrapping it in a GenericMessage with null as payload?
  • Or should the interceptor skip null messages altogether?

Thanks in advance!

I’m working with 2.0.0.M6 btw
Dave Syer
@dsyer
Feb 14 2018 14:57
The interceptor should skip nulls probably
Tim Ysewyn
@TYsewyn
Feb 14 2018 15:02
Thanks @dsyer, I’ll start working towards that solution :)
You can expect a PR in the near future :D
Marcin Grzejszczak
@marcingrzejszczak
Feb 14 2018 15:06
@TYsewyn this might be related to spring-cloud/spring-cloud-stream#1219
but maybe not
oh that's sth completely different
yeah the interceptor should skip nulls for sure
Spencer Gibb
@spencergibb
Feb 14 2018 16:06
@ghoddg it's not a bug, but a feature enhancement to use containers other than netty
ghoddg
@ghoddg
Feb 14 2018 17:11
@spencergibb I am starting my api gateway service with tomcat and when i hit my api , it is giving me the error
ghoddg
@ghoddg
Feb 14 2018 17:18
Spring Cloud Gateway is not supporting with tomcat?
Spencer Gibb
@spencergibb
Feb 14 2018 17:51
not yet
ghoddg
@ghoddg
Feb 14 2018 17:52
@spencergibb Thanks for update
Tim Ysewyn
@TYsewyn
Feb 14 2018 18:30
@marcingrzejszczak fixed that issue for you with #861
Tim Ysewyn
@TYsewyn
Feb 14 2018 18:38
weird, it worked locally. I’ll rerun the test suite again on my laptop and will fix the errors when they do appear 🙂
Tim Ysewyn
@TYsewyn
Feb 14 2018 20:14
@marcingrzejszczak @spencergibb can you guys check the build on circle ci, or restart it?
Spencer Gibb
@spencergibb
Feb 14 2018 20:15
@TYsewyn what build?
Tim Ysewyn
@TYsewyn
Feb 14 2018 20:15
I triple checked all tests, running it both in my ide and using maven. Everything is running fine locally 🤔
Spencer Gibb
@spencergibb
Feb 14 2018 20:35
rebuilding
Tim Ysewyn
@TYsewyn
Feb 14 2018 20:50
Thanks @spencergibb!
Siamak Khoubyari
@khoubyari
Feb 14 2018 21:01
I would like to use the kubernetes PropertySource and secret PS with our Spring Boot projects. If I don't have k8s running in one of my profiles (e.g. "unit-test" profile on my laptop), is there any way to still run my app (e.g. supply the configs using one of Spring Boot native mechanisms)?
Siamak Khoubyari
@khoubyari
Feb 14 2018 21:30
The above question is in the context of using the spring-cloud-kubernetes project
Patricia Guimaraes
@pguimaraes
Feb 14 2018 22:30
Do the Spring Cloud projects use the RestTemplateBuilder auto-configured by Spring Boot, as mentioned at https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-restclient.html? If I create a RestTemplateCustomizer Bean to customize a RestTemplate, will Spring Cloud use the customized RestTemplate or will it use another instance of RestTemplate?