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

13th
Mar 2018
玹霖
@SoftwareKing
Mar 13 2018 12:24
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'httpHandler' defined in class path resource [org/springframework/boot/autoconfigure/web/reactive/HttpHandlerAutoConfiguration$AnnotationConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.http.server.reactive.HttpHandler]: Factory method 'httpHandler' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'webHandler' defined in class path resource [org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfiguration$EnableWebFluxConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'routePredicateHandlerMapping' defined in class path resource [org/springframework/cloud/gateway/config/GatewayAutoConfiguration.class]: Unsatisfied dependency expressed through method 'routePredicateHandlerMapping' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cachedCompositeRouteLocator' defined in class path resource [org/springframework/cloud/gateway/config/GatewayAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.gateway.route.RouteLocator]: Factory method 'cachedCompositeRouteLocator' threw exception; nested exception is java.lang.IllegalArgumentException: Unable to find RoutePredicateFactory with name Betweeen
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:587) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1250) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1099) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:205) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.getHttpHandler(ReactiveWebServerApplicationContext.java:155) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.createWebServer(ReactiveWebServerApplicationContext.java:99) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.onRefresh(ReactiveWebServerApplicationContext.java:73) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
... 13 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.http.server.reactive.HttpHandler]: Factory m
spring:
cloud:
gateway:
routes:
  - id: between_route
    uri: http://example.org
    predicates:
    - Betweeen=2017-01-20T17:42:47.789-07:00[America/Denver], 2017-01-21T17:42:47.789-07:00[America/Denver]
Abhishek Dujari
@abshkd
Mar 13 2018 12:26
man thats the best dependency error I have seen
玹霖
@SoftwareKing
Mar 13 2018 12:29
@spencergibb when i use predicates:
    - Betweeen=2017-01-20T17:42:47.789-07:00[America/Denver], 2017-01-21T17:42:47.789-07:00[America/Denver],exception:Caused by: java.lang.IllegalArgumentException: Unable to find RoutePredicateFactory with name Betweeen
Bhavani J
@BhavaniJ2_twitter
Mar 13 2018 15:50
Hello, I have integrated my SpringBoot application with Vault using TOKEN authentication. Vault token credentials are fetched as User Provided Services from Cloud Foundry as shown
System-Provided:
{
 "VCAP_SERVICES": {
  "user-provided": [
   {
    "credentials": {
     "token": "{cipher}bd1196d59d93c0ef52edef8f0f473b43e03d335fdc2d3ed2f270250994108e007a94edf7797ab3fa28d50db90ced0c7840b516d9041dd7771098c9d6eb6dae18"
    },
    "label": "user-provided",
    "name": "vault-service",
    "syslog_drain_url": "",
    "tags": [],
    "volume_mounts": []
   }
  ]
 }
}
Here is the error logs to decrypt the token while deploying the app:
  2018-03-13T00:31:03.37-0500 [APP/PROC/WEB/0] OUT 2018-03-13 05:31:03.376 ERROR 12 --- [           main] o.s.boot.SpringApplication               : Application startup failed
   2018-03-13T00:31:03.37-0500 [APP/PROC/WEB/0] OUT java.lang.IllegalStateException: Cannot decrypt: key=vcap.services.vault-service.credentials.token
   2018-03-13T00:31:03.37-0500 [APP/PROC/WEB/0] OUT     at org.springframework.cloud.bootstrap.encrypt.EnvironmentDecryptApplicationInitializer.decrypt(EnvironmentDecryptApplicationInitializer.java:202)
   2018-03-13T00:31:03.37-0500 [APP/PROC/WEB/0] OUT     at org.springframework.cloud.bootstrap.encrypt.EnvironmentDecryptApplicationInitializer.decrypt(EnvironmentDecryptApplicationInitializer.java:166)
   2018-03-13T00:31:03.37-0500 [APP/PROC/WEB/0] OUT     at org.springframework.cloud.bootstrap.encrypt.EnvironmentDecryptApplicationInitializer.initialize(EnvironmentDecryptApplicationInitializer.java:96)
   2018-03-13T00:31:03.37-0500 [APP/PROC/WEB/0] OUT     at org.springframework.cloud.bootstrap.BootstrapApplicationListener$DelegatingEnvironmentDecryptApplicationInitializer.initialize(BootstrapApplicationListener.java:394)
   2018-03-13T00:31:03.37-0500 [APP/PROC/WEB/0] OUT     at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:567)
   2018-03-13T00:31:03.37-0500 [APP/PROC/WEB/0] OUT     at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:338)
   2018-03-13T00:31:03.37-0500 [APP/PROC/WEB/0] OUT     at org.springframework.boot.SpringApplication.run(SpringApplication.java:301)
   2018-03-13T00:31:03.37-0500 [APP/PROC/WEB/0] OUT     at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
   2018-03-13T00:31:03.37-0500 [APP/PROC/WEB/0] OUT     at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
   2018-03-13T00:31:03.37-0500 [APP/PROC/WEB/0] OUT     at com.monsanto.finance.SaleSurveyToolApplicationKt.main(SaleSurveyToolApplication.kt:19)
   2018-03-13T00:31:03.37-0500 [APP/PROC/WEB/0] OUT     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   2018-03-13T00:31:03.37-0500 [APP/PROC/WEB/0] OUT     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   2018-03-13T00:31:03.37-0500 [APP/PROC/WEB/0] OUT     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   2018-03-13T00:31:03.37-0500 [APP/PROC/WEB/0] OUT     at java.lang.reflect.Method.invoke(Method.java:498)
   2018-03-13T00:31:03.37-0500 [APP/PROC/WEB/0] OUT     at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
   2018-03-13T00:31:03.37-0500 [APP/PROC/WEB/0] OUT     at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
   2018-03-13T00:31:03.37-0500 [APP/PROC/WEB/0] OUT     at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
   2018-03-13T00:31:03.37-0500 [APP/PROC/WEB/0] OUT     at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
   2018-03-13T00:31:03.37-0500 [APP/PROC/WEB/0] OUT Caused by: java.lang.UnsupportedOperationException: No decryption for FailsafeTextEncryptor. Did you configure the keystore correctly?
   2018-03-13T00:31:03.37-0500 [APP/PROC/WEB/0] OUT     at org.springframework.cloud.bootstrap.encrypt.EncryptionBootstrapConfiguration$FailsafeTextEncryptor.decrypt(EncryptionBootstrapConfiguration.java:159)
   2018-03-13T00:31:03.37-0500 [APP/PROC/WEB/0] OUT     at org.springframework.cloud.bootstrap.encrypt.EnvironmentDecryptApplicationInitializer.decrypt(EnvironmentDecryptApplicationInitializer.java:194)
I added below dependencies in pom.xml
<dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-crypto</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-rsa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-vault-config</artifactId>
        </dependency>
Am I missing or doing anything incorrect? Any help is appreciated. Thank you!
Spencer Gibb
@spencergibb
Mar 13 2018 15:54
@mp911de are you around?
@SoftwareKing replied to gateway issue
Mark Paluch
@mp911de
Mar 13 2018 16:36
@BhavaniJ2_twitter You're encrypting the Vault token? Do you have set up your crypto config (encrypt. keystore. …)?
Spring Cloud Vault isn't doing anything to your config at that point
lnxmad
@lnxmad
Mar 13 2018 18:13
hey guys, question about spring cloud gateway,
I have services registered in eureka with a version included in the name (my-service-v1), and I'm trying to setup a route that can take a version out of the path, and use it within the URI i.e /v1/some-resource -> URI: lb://my-service-v{the version from url}
Spencer Gibb
@spencergibb
Mar 13 2018 18:18
@lnxmad you'd have to write a filter
Uri Goldstein
@urig
Mar 13 2018 18:19
Hello. Is this the right place to ask for help with Eureka?
Spencer Gibb
@spencergibb
Mar 13 2018 18:19
if you are using it with spring cloud, then yes
lnxmad
@lnxmad
Mar 13 2018 18:19
ah, ok. I'll dig into that a bit. Thanks @spencergibb . BTW are you in Boston tomorrow?
Uri Goldstein
@urig
Mar 13 2018 18:19
Yes, I am, thanks. Trying to build a demo of how it's integrated into Spring Cloud.
Spencer Gibb
@spencergibb
Mar 13 2018 18:20
no, ryan baxter is
@urig then yes
lnxmad
@lnxmad
Mar 13 2018 18:20
Stay away from the snow :)
Uri Goldstein
@urig
Mar 13 2018 18:21
When I start my Eureka server on localhost I see an exception "Cannot execute request on any known server"
I also see it in my client spring app and I suspect it's the reason why Feign fails to work with Eureka. (Works with explicit URL though).
The error I'm getting in the client side responses is:
{
    "timestamp": "2018-03-13T18:12:50.251+0000",
    "status": 500,
    "error": "Internal Server Error",
    "message": "status 404 reading BillingClient#chargeCreditCard(CreditCard); content:\n{\"timestamp\":\"2018-03-13T18:12:50.247+0000\",\"status\":404,\"error\":\"Not Found\",\"message\":\"No message available\",\"path\":\"/creditCardCharge\"}",
    "path": "/checkout/book/1"
}
BillingClient is Feign...
Spencer Gibb
@spencergibb
Mar 13 2018 18:23
by default eureka server tries to connect to peers
Uri Goldstein
@urig
Mar 13 2018 18:24
Can I tell it not to?
Is this what I'm missing: eureka.numberRegistrySyncRetries=0 ?
Spencer Gibb
@spencergibb
Mar 13 2018 18:27
On the server
eureka:
  client:
    registerWithEureka: false
    fetchRegistry: false
Uri Goldstein
@urig
Mar 13 2018 18:27
I actually don't have the client dependency on the server at all. Do I still need to do this?
Spencer Gibb
@spencergibb
Mar 13 2018 18:31
the server is a client of its peers
Uri Goldstein
@urig
Mar 13 2018 18:32
Understood. But for this demo on localhost with only one server instance, do I have to add the client dependency?
Also, why are so many config examples given in yaml? In which .yml file should I put them?
And thanks for helping again Spencer. I really appreciate it.
Spencer Gibb
@spencergibb
Mar 13 2018 18:37
it's already part of server. put it in application.yml
Uri Goldstein
@urig
Mar 13 2018 18:39
I'm using application.properties can I have both that and application.yml side by side?
Also: The config you gave me worked. Server no longer shows exception.
However, all clients show the error (Cannot execute request on any known server)
I guess that explains why my clients are unable to find each other? How can I further investigate?
Bhavani J
@BhavaniJ2_twitter
Mar 13 2018 18:43
@mp911de Thank you for your inputs! I am now setting encrypt key as environment variable in Could Foundry for the spring boot app:
User-Provided:
ENCRYPT_KEY: 1B61EA9E82B5427E990FCAA21C040270
JAVA_OPTS: -Dspring.profiles.active=dev

No running env variables have been set

No staging env variables have been set
Now I get a different error:
  2018-03-13T13:30:52.88-0500 [APP/PROC/WEB/0] OUT 18:30:52.881 [main] INFO  o.c.r.s.DataSourceCloudServiceBeanFactoryPostProcessor - No matching service found. Skipping auto-reconfiguration.
   2018-03-13T13:30:53.33-0500 [APP/PROC/WEB/0] OUT org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'vaultPropertySource#0': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.vault.core.env.VaultPropertySource]: Constructor threw exception; nested exception is org.springframework.vault.VaultException: Status 403 secret/value-capture-test/np/db/eventstore/dev: permission denied
   2018-03-13T13:30:53.33-0500 [APP/PROC/WEB/0] OUT     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
   2018-03-13T13:30:53.33-0500 [APP/PROC/WEB/0] OUT     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
   2018-03-13T13:30:53.33-0500 [APP/PROC/WEB/0] OUT     at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:178)
   2018-03-13T13:30:53.33-0500 [APP/PROC/WEB/0] OUT     at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:525)
   2018-03-13T13:30:53.33-0500 [APP/PROC/WEB/0] OUT     at com.monsanto.finance.SaleSurveyToolApplicationKt.main(SaleSurveyToolApplication.kt:19)
   2018-03-13T13:30:53.33-0500 [APP/PROC/WEB/0] OUT     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   2018-03-13T13:30:53.33-0500 [APP/PROC/WEB/0] OUT     at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:154)
   2018-03-13T13:30:53.33-0500 [APP/PROC/WEB/0] OUT     at org.springframework.vault.core.env.VaultPropertySource.doGetProperties(VaultPropertySource.java:157)
   2018-03-13T13:30:53.33-0500 [APP/PROC/WEB/0] OUT     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
   2018-03-13T13:30:53.33-0500 [APP/PROC/WEB/0] OUT     ... 32 common frames omitted
   2018-03-13T13:30:53.33-0500 [APP/PROC/WEB/0] OUT     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
   2018-03-13T13:30:53.33-0500 [APP/PROC/WEB/0] OUT     at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:178)
   2018-03-13T13:30:53.33-0500 [APP/PROC/WEB/0] OUT     at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:525)
   2018-03-13T13:30:53.33-0500 [APP/PROC/WEB/0] OUT     at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
   2018-03-13T13:30:53.33-0500 [APP/PROC/WEB/0] OUT     at java.lang.reflect.Method.invoke(Method.java:498)
   2018-03-13T13:30:53.33-0500 [APP/PROC/WEB/0] OUT Caused by: org.springframework.vault.VaultException: Status 403 secret/value-capture-test/np/db/eventstore/dev: permission denied
   2018-03-13T13:30:53.33-0500 [APP/PROC/WEB/0] OUT     at org.springframework.vault.core.VaultTemplate.doRead(VaultTemplate.java:327)
   2018-03-13T13:30:53.33-0500 [APP/PROC/WEB/0] OUT     at org.springframework.vault.core.VaultTemplate.read(VaultTemplate.java:227)
   2018-03-13T13:30:53.33-0500 [APP/PROC/WEB/0] OUT     at org.springframework.vault.core.env.VaultPropertySource.loadProperties(VaultPropertySource.java:124)
   2018-03-13T13:30:53.33-0500 [APP/PROC/WEB/0] OUT     at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:142)
   2018-03-13T13:30:53.33-0500 [APP/PROC/WEB/0] OUT     ... 32 common frames omitted

This is my VautConfig configuration:

@Configuration
@VaultPropertySource("\${db.eventstore.secret.path}")
@ConditionalOnExpression("\${spring.cloud.vault.enabled:true}")
class VaultConfig

And defined vault secret path in application.properties:

#DB
db.eventstore.secret.path=secret/value-capture-test/np/db/eventstore/dev
When I use the plain un-encrypted token, I am able to access the Vault configuration successfully. But receiving above Status 403 secret/value-capture-test/np/db/eventstore/dev: permission denied when using encyrpted token.
Spencer Gibb
@spencergibb
Mar 13 2018 18:48
@urig what does your client configuration look like
lnxmad
@lnxmad
Mar 13 2018 18:49
@spencergibb whats the best way to have the gateway pick up my custom GatewayFilterFactory?
Spencer Gibb
@spencergibb
Mar 13 2018 18:49
create a @Bean
lnxmad
@lnxmad
Mar 13 2018 18:49
:thumbsup:
and would I want this filter to modify the URI somehow?
Mark Paluch
@mp911de
Mar 13 2018 18:52
Looks like the token does not get decrypted properly. You can inject VaultProperties into a bootstrap context configuration and then inspect it to see what’s inside. You need to add your Config to a spring.factories file (see Spring Cloud Vault jar for an example)
Uri Goldstein
@urig
Mar 13 2018 18:52
@spencergibb I fixed it. I had two issues:
Spencer Gibb
@spencergibb
Mar 13 2018 18:53
@lnxmad yes
lnxmad
@lnxmad
Mar 13 2018 18:53
:thumbsup:
Uri Goldstein
@urig
Mar 13 2018 18:53
  1. I had the wrong resource name in my @RequestMapping
  2. I think I was missing some bits in the client config:
    eureka.preferSameZone=true
    eureka.shouldUseDns=false
    eureka.decoderName=JacksonJson
Many thanks for helping @spencergibb !
BTW, is the decoderName bit really important? :)
Spencer Gibb
@spencergibb
Mar 13 2018 18:54
@urig those aren't spring cloud eureka configuration keys
Netflix Eureka is "below" Spring Cloud Eureka, right? What's a sample config for Spring Cloud Eureka?
Spencer Gibb
@spencergibb
Mar 13 2018 18:56
spring cloud doesn't use a eureka specific config file
what does "below" mean?
Uri Goldstein
@urig
Mar 13 2018 18:57
I mean Spring Cloud Eureka depends on and utilizes Netflix as a "lower level" dependency...?
Please don't tell me they're unrelated because then my head will explode :worried:
Spencer Gibb
@spencergibb
Mar 13 2018 18:59
yes, netflix eureka is a dependency of spring cloud eureka. but we configure it differently
Uri Goldstein
@urig
Mar 13 2018 18:59
Is there perhaps a reference configuration?
lnxmad
@lnxmad
Mar 13 2018 19:09
@spencergibb in order to modify the URI, should I be going after the exchange attributes? Route route = exchange.getAttribute(ServerWebExchangeUtils.GATEWAY_ROUTE_ATTR);
Spencer Gibb
@spencergibb
Mar 13 2018 19:10
GATEWAY_REQUEST_URL_ATTR.
lnxmad
@lnxmad
Mar 13 2018 19:11
:thumbsup:
not seeing that while debugging
only have 3, uriTemplateVars, handlerMapper, and gatewayRoute
perhaps the ordering of the filter
oh, am I suppose to set it?
Bhavani J
@BhavaniJ2_twitter
Mar 13 2018 19:21

@mp911de Here is my bootstrap.yml with vault properties

spring.cloud.vault:
    host: vault.agro.services
    port: 443
    authentication: TOKEN
    token: ${vcap.services.vault-service.credentials.token}
    generic:
        enabled: false

As you suggested, I added META-INF/spring.factories under resources folder in spring boot app:

org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.monsanto.finance.VaultConfig

And set AutoConfigureOrder to Ordered.HIGHEST_PRECEDENCE for custom VaultConfig

@Configuration
@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE)
@VaultPropertySource("\${db.eventstore.secret.path}")
@ConditionalOnExpression("\${spring.cloud.vault.enabled:true}")
class VaultConfig

Still getting the same permission denied error

  2018-03-13T14:14:39.42-0500 [APP/PROC/WEB/0] OUT Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.vault.core.env.VaultPropertySource]: Constructor threw exception; nested exception is org.springframework.vault.VaultException: Status 403 secret/value-capture-test/np/db/eventstore/dev: permission denied
   2018-03-13T14:14:39.42-0500 [APP/PROC/WEB/0] OUT     at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:154)
   2018-03-13T14:14:39.42-0500 [APP/PROC/WEB/0] OUT     at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:122)
   2018-03-13T14:14:39.42-0500 [APP/PROC/WEB/0] OUT     at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:271)
   2018-03-13T14:14:39.42-0500 [APP/PROC/WEB/0] OUT     ... 30 common frames omitted
   2018-03-13T14:14:39.42-0500 [APP/PROC/WEB/0] OUT Caused by: org.springframework.vault.VaultException: Status 403 secret/value-capture-test/np/db/eventstore/dev: permission denied
   2018-03-13T14:14:39.42-0500 [APP/PROC/WEB/0] OUT     at org.springframework.vault.client.VaultResponses.buildException(VaultResponses.java:83)
   2018-03-13T14:14:39.42-0500 [APP/PROC/WEB/0] OUT     at org.springframework.vault.core.VaultTemplate$2.doWithRestOperations(VaultTemplate.java:341)
   2018-03-13T14:14:39.42-0500 [APP/PROC/WEB/0] OUT     at org.springframework.vault.core.VaultTemplate.doWithSession(VaultTemplate.java:318)
   2018-03-13T14:14:39.42-0500 [APP/PROC/WEB/0] OUT     at org.springframework.vault.core.VaultTemplate.doRead(VaultTemplate.java:327)
   2018-03-13T14:14:39.42-0500 [APP/PROC/WEB/0] OUT     at org.springframework.vault.core.VaultTemplate.read(VaultTemplate.java:227)
   2018-03-13T14:14:39.42-0500 [APP/PROC/WEB/0] OUT     at org.springframework.vault.core.env.VaultPropertySource.doGetProperties(VaultPropertySource.java:157)
   2018-03-13T14:14:39.42-0500 [APP/PROC/WEB/0] OUT     at org.springframework.vault.core.env.VaultPropertySource.loadProperties(VaultPropertySource.java:124)
   2018-03-13T14:14:39.42-0500 [APP/PROC/WEB/0] OUT     at org.springframework.vault.core.env.VaultPropertySource.<init>(VaultPropertySource.java:111)
   2018-03-13T14:14:39.42-0500 [APP/PROC/WEB/0] OUT     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
   2018-03-13T14:14:39.42-0500 [APP/PROC/WEB/0] OUT     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
   2018-03-13T14:14:39.42-0500 [APP/PROC/WEB/0] OUT     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
   2018-03-13T14:14:39.42-0500 [APP/PROC/WEB/0] OUT     at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
   2018-03-13T14:14:39.42-0500 [APP/PROC/WEB/0] OUT     at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:142)
Uri Goldstein
@urig
Mar 13 2018 19:30
@spencergibb apologies for nagging, but is there a getting started guide to Spring Cloud Eureka? Somewhere where I can see sample setup and configuration? Thanks :)
Spencer Gibb
@spencergibb
Mar 13 2018 19:31
@lnxmad order is important
lnxmad
@lnxmad
Mar 13 2018 19:45
@spencergibb is GATEWAY_REQUEST_URL_ATTR what I'm looking for..if I'm trying to change the lb://service URI?
Spencer Gibb
@spencergibb
Mar 13 2018 19:46
is that what's in the attr?
lnxmad
@lnxmad
Mar 13 2018 19:51
no I only see what ran after SetPath filter
the URI is on GATEWAY_ROUTE_ATTR
but I dont know if I want to modify that
lnxmad
@lnxmad
Mar 13 2018 20:03
disregard, it is in GATEWAY_REQUEST_URL_ATTR.. I thought it was only a string
Uri Goldstein
@urig
Mar 13 2018 20:04
@spencergibb thank you!
lnxmad
@lnxmad
Mar 13 2018 20:15
I can't seem to get the ordering correct. I implement Ordered and set it 1 less than LoadBalancerClientFilter but somehow its getting set far too low and its running too early in the chain
lnxmad
@lnxmad
Mar 13 2018 20:31
6.1 Combined Global Filter and GatewayFilter Ordering
TODO: document ordering
@spencergibb
Spencer Gibb
@spencergibb
Mar 13 2018 20:35
;-)
lnxmad
@lnxmad
Mar 13 2018 20:35
:)
Spencer Gibb
@spencergibb
Mar 13 2018 20:36
did you try +1. -1 is before
lnxmad
@lnxmad
Mar 13 2018 20:36
when breaking, I can see the chain and the two filters I have on the route are set to 1 and 2 which is how I have them defined
perhaps its ignoring the getOrder()
The globals seem to all have 10000+
Spencer Gibb
@spencergibb
Mar 13 2018 20:38
set logging.level.org.springframework.cloud.gateway=DEBUG and it will show you the combined ordering
lnxmad
@lnxmad
Mar 13 2018 20:41
yeah the order is set to 2
on mine
Only thing I can think of is the global filters are always after
Spencer Gibb
@spencergibb
Mar 13 2018 20:48
did you try 9999
lnxmad
@lnxmad
Mar 13 2018 20:51
always resets to 2
which I imagine corresponds with the position I have it under the route
[
OrderedGatewayFilter{delegate=GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.NettyWriteResponseFilter@3086f480}, order=-1}, 
OrderedGatewayFilter{delegate=org.springframework.cloud.gateway.filter.factory.RemoveNonProxyHeadersGatewayFilterFactory$$Lambda$304/1529457505@5999b9cf, order=1}, 
OrderedGatewayFilter{delegate=org.springframework.cloud.gateway.filter.factory.SetPathGatewayFilterFactory$$Lambda$306/188193734@79351a3, order=1}, 
OrderedGatewayFilter{delegate=com.test.VersionDiscoveryGatewayFilterFactory$$Lambda$307/927744186@38be17e2, order=2}, 
OrderedGatewayFilter{delegate=GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.RouteToRequestUrlFilter@126f8f24}, order=10000}, 
OrderedGatewayFilter{delegate=GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.LoadBalancerClientFilter@48cb2d73}, order=10100}, 
OrderedGatewayFilter{delegate=GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.NettyRoutingFilter@243bf087}, order=2147483647}, 
OrderedGatewayFilter{delegate=GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.ForwardRoutingFilter@35e98af}, order=2147483647}, 
OrderedGatewayFilter{delegate=GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.WebsocketRoutingFilter@781aff8b}, order=2147483647}
Spencer Gibb
@spencergibb
Mar 13 2018 21:02
how are you setting the order and what version are you using?
lnxmad
@lnxmad
Mar 13 2018 21:03
VersionDiscoveryGatewayFilterFactory implements Ordered and my getOrder() returns 10050
Finchley.M7
so 2.0.0.M7
Spencer Gibb
@spencergibb
Mar 13 2018 21:07
M8 is the latest
I recall an ordering issue
how are you configuring the filter on the route?
lnxmad
@lnxmad
Mar 13 2018 21:18
as part of the yml
filters:
   - VersionDiscovery...
I'll try M8
Spencer Gibb
@spencergibb
Mar 13 2018 21:21
can you show the full configuration?
lnxmad
@lnxmad
Mar 13 2018 21:22
spring:
  cloud:
    gateway:
      routes:
      - id: my-service
        uri: lb://bogus
        predicates:
        - Path=/api/v{version}/{segment}
        filters:
        - SetPath=/{segment}
        - VersionDiscovery=version,my-service
Spencer Gibb
@spencergibb
Mar 13 2018 21:23
there is an order attribute, sibling of uri (ie same level)
lnxmad
@lnxmad
Mar 13 2018 21:23
hm
isnt that the order of the route though?
not the filters
Spencer Gibb
@spencergibb
Mar 13 2018 21:24
ah, yes, sorry
lnxmad
@lnxmad
Mar 13 2018 21:25
no dice with M8 though there appears to be one less filter.. didnt catch which one
Spencer Gibb
@spencergibb
Mar 13 2018 21:25
Ok, I see
I think you may be able to do this with the java dsl, but not config file, since the order you defined is on the factory, not the filter it creates
@lnxmad file an issue? sorry for the runaround
lnxmad
@lnxmad
Mar 13 2018 21:29
hm
yeah I'll dig in a bit more and raise an issue
Spencer Gibb
@spencergibb
Mar 13 2018 21:32
the dsl has a GatewayFilterSpec.filter(GatewayFilter, order) method that you can explicitly set the order
lnxmad
@lnxmad
Mar 13 2018 21:33
though in the factory, couldnt I just return a OrderedGatewayFilter during apply?
return new OrderedGatewayFilter((exchange, chain) -> {

            return chain.filter(exchange);
        }, 10050);
dont think thats working
lnxmad
@lnxmad
Mar 13 2018 21:40
I guess I could make a global filter
local filter to set some additional attributes, and a global to read them and update URI
Spencer Gibb
@spencergibb
Mar 13 2018 21:44
could work
Andrew Fitzgerald
@fitzoh
Mar 13 2018 21:54
Just looked at the tuple -> binding changes in scg @spencergibb ... that’s awesome, feels a lot cleaner
Spencer Gibb
@spencergibb
Mar 13 2018 21:58
thx
lnxmad
@lnxmad
Mar 13 2018 22:35
@spencergibb Got that working.. thanks for the help!
Spencer Gibb
@spencergibb
Mar 13 2018 22:35
nice
lnxmad
@lnxmad
Mar 13 2018 22:35
one other question, whats the best way to handle exceptions within gateway
instead of returning whitelabel
I see MVC is not compatible yet
Spencer Gibb
@spencergibb
Mar 13 2018 22:37
depends, you probably just want to set a http response status code
lnxmad
@lnxmad
Mar 13 2018 22:37
that would be fine, I dont need anything fancy, though when I get exceptions like NotFoundException via LoadBalancer filter, I want to handle gracefully
just dont know where to put it, is it a @ControllerAdvice? or something else
think I found it ErrorWebExceptionHandler
that did it :thumbsup:
Spencer Gibb
@spencergibb
Mar 13 2018 22:48
can you show me what you did with that?
lnxmad
@lnxmad
Mar 13 2018 22:49
@Bean
    public ErrorWebExceptionHandler getErrorWebExceptionHandler() {
        return (exchange, ex) -> {
            exchange.getResponse().setStatusCode(HttpStatus.NOT_FOUND);

            return Mono.empty();
        };
    }
Spencer Gibb
@spencergibb
Mar 13 2018 22:49
thanks
lnxmad
@lnxmad
Mar 13 2018 22:51
Though the Mono.empty() could be Mono.empty().then() not sure which the reactor team prefers