OpenLiberty / open-liberty

Open Liberty is a highly composable, fast to start, dynamic application server runtime environment
https://openliberty.io
Eclipse Public License 2.0
1.15k stars 587 forks source link

Help running springboot with spring cloud consul #13768

Open monwolf opened 4 years ago

monwolf commented 4 years ago

Good Morning,

I'm trying to migrate from the classical approach "java -jar myApp.jar" to use openliberty as an application server getting the benefits of the lib cache.

I haven't been able to start the application because some of the steps such as download the config from consul at start time are not happening.

We a re using sping.cloud.consul and spring.cloud.vault to get the properties and the secrets of the app:

https://cloud.spring.io/spring-cloud-consul/reference/html/ https://cloud.spring.io/spring-cloud-vault/reference/html/

We are trying to follow the petclinic example found in your github:

https://github.com/OpenLiberty/ci.docker/blob/master/samples/spring-petclinic/Dockerfile

But after following the steps. We can't see any request to consul in the startup log. only Vault is running (I set logging.level.org.springframework.web=DEBUG):

Launching defaultServer (Open Liberty 20.0.0.8/wlp-1.0.43.cl200820200721-1900) on Eclipse OpenJ9 VM, version 11.0.8+10 (en_US)
[AUDIT   ] CWWKE0001I: The server defaultServer has been launched.
[AUDIT   ] CWWKG0093A: Processing configuration drop-ins resource: /opt/ol/wlp/usr/servers/defaultServer/configDropins/defaults/keystore.xml
[AUDIT   ] CWWKG0093A: Processing configuration drop-ins resource: /opt/ol/wlp/usr/servers/defaultServer/configDropins/defaults/open-default-port.xml
[AUDIT   ] CWWKZ0058I: Monitoring dropins for applications.
2020-09-01 12:01:41.782  INFO [my-rest-app,,,] 1 --- [ecutor-thread-3] o.s.s.c.ThreadPoolTaskScheduler          : Initializing ExecutorService
  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.2.4.RELEASE)
2020-09-01 12:01:42.326 DEBUG [my-rest-app,,,] 1 --- [ecutor-thread-3] o.s.web.client.RestTemplate              : HTTP GET https://consulserver:8200/v1/sys/internal/ui/mounts/secret/osp/secrets
2020-09-01 12:01:42.444 DEBUG [my-rest-app,,,] 1 --- [ecutor-thread-3] o.s.web.client.RestTemplate              : Accept=[application/json, application/*+json]
2020-09-01 12:01:42.457 DEBUG [my-rest-app,,,] 1 --- [ecutor-thread-3] o.s.web.client.RestTemplate              : HTTP GET https://consulserver:8200/v1/auth/token/lookup-self
2020-09-01 12:01:42.461 DEBUG [my-rest-app,,,] 1 --- [ecutor-thread-3] o.s.web.client.RestTemplate              : Accept=[application/json, application/*+json]
2020-09-01 12:01:42.949 DEBUG [my-rest-app,,,] 1 --- [ecutor-thread-3] o.s.web.client.RestTemplate              : Response 200 OK
2020-09-01 12:01:42.953 DEBUG [my-rest-app,,,] 1 --- [ecutor-thread-3] o.s.web.client.RestTemplate              : Reading to [org.springframework.vault.support.VaultResponse]
2020-09-01 12:01:43.000  INFO [my-rest-app,,,] 1 --- [ecutor-thread-3] o.s.v.a.LifecycleAwareSessionManager     : Scheduling Token renewal
2020-09-01 12:01:43.055 DEBUG [my-rest-app,,,] 1 --- [ecutor-thread-3] o.s.web.client.RestTemplate              : Response 200 OK
2020-09-01 12:01:43.056 DEBUG [my-rest-app,,,] 1 --- [ecutor-thread-3] o.s.web.client.RestTemplate              : Reading to [org.springframework.vault.support.VaultResponse]
2020-09-01 12:01:43.060 DEBUG [my-rest-app,,,] 1 --- [ecutor-thread-3] o.s.web.client.RestTemplate              : HTTP GET https://consulserver:8200/v1/secret/osp/secrets
2020-09-01 12:01:43.061 DEBUG [my-rest-app,,,] 1 --- [ecutor-thread-3] o.s.web.client.RestTemplate              : Accept=[application/json, application/*+json]
2020-09-01 12:01:43.111 DEBUG [my-rest-app,,,] 1 --- [ecutor-thread-3] o.s.web.client.RestTemplate              : Response 200 OK
2020-09-01 12:01:43.112 DEBUG [my-rest-app,,,] 1 --- [ecutor-thread-3] o.s.web.client.RestTemplate              : Reading to [org.springframework.vault.support.VaultResponse]
2020-09-01 12:01:43.131  INFO [my-rest-app,,,] 1 --- [ecutor-thread-3] b.c.PropertySourceBootstrapConfiguration : Located property source: [BootstrapPropertySource {name='bootstrapProperties-secret/osp/secrets'}]
2020-09-01 12:01:43.358  INFO [my-rest-app,,,] 1 --- [ecutor-thread-3] b.c.PropertySourceBootstrapConfiguration : Located property source: [BootstrapPropertySource {name='bootstrapProperties-osp/my-rest-app.yml'}, BootstrapPropertySource {name='bootstrapProperties-osp/application.yml'}]
2020-09-01 12:01:43.441  INFO [my-rest-app,,,] 1 --- [ecutor-thread-3] c.a.multiavail.flexpricer.Application    : No active profile set, falling back to default profiles: default
2020-09-01 12:01:45.444  INFO [my-rest-app,,,] 1 --- [ecutor-thread-3] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2020-09-01 12:01:45.445  INFO [my-rest-app,,,] 1 --- [ecutor-thread-3] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2020-09-01 12:01:45.614  INFO [my-rest-app,,,] 1 --- [ecutor-thread-3] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 159ms. Found 2 JPA repository interfaces.
2020-09-01 12:01:45.615  INFO [my-rest-app,,,] 1 --- [ecutor-thread-3] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2020-09-01 12:01:45.616  INFO [my-rest-app,,,] 1 --- [ecutor-thread-3] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2020-09-01 12:01:45.625  INFO [my-rest-app,,,] 1 --- [ecutor-thread-3] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 8ms. Found 1 JPA repository interfaces.
2020-09-01 12:01:45.693  INFO [my-rest-app,,,] 1 --- [ecutor-thread-3] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2020-09-01 12:01:45.694  INFO [my-rest-app,,,] 1 --- [ecutor-thread-3] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data MongoDB repositories in DEFAULT mode.
2020-09-01 12:01:45.710  INFO [my-rest-app,,,] 1 --- [ecutor-thread-3] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 15ms. Found 3 MongoDB repository interfaces.
2020-09-01 12:01:46.489  WARN [my-rest-app,,,] 1 --- [ecutor-thread-3] o.s.boot.actuate.endpoint.EndpointId     : Endpoint ID 'service-registry' contains invalid characters, please migrate to a valid format.
2020-09-01 12:01:46.894  INFO [my-rest-app,,,] 1 --- [ecutor-thread-3] o.s.cloud.context.scope.GenericScope     : BeanFactory id=01d08e1f-e727-308b-afb5-c5eed00b7862
2020-09-01 12:01:47.319  INFO [my-rest-app,,,] 1 --- [ecutor-thread-3] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.ws.config.annotation.DelegatingWsConfiguration' of type [org.springframework.ws.config.annotation.DelegatingWsConfiguration$$EnhancerBySpringCGLIB$$ad092856] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-09-01 12:01:47.398  INFO [my-rest-app,,,] 1 --- [ecutor-thread-3] .w.s.a.s.AnnotationActionEndpointMapping : Supporting [WS-Addressing August 2004, WS-Addressing 1.0]
2020-09-01 12:01:47.675  INFO [my-rest-app,,,] 1 --- [ecutor-thread-3] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration' of type [org.springframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-09-01 12:01:47.685  INFO [my-rest-app,,,] 1 --- [ecutor-thread-3] trationDelegate$BeanPostProcessorChecker : Bean 'objectPostProcessor' of type [org.springframework.security.config.annotation.configuration.AutowireBeanFactoryObjectPostProcessor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-09-01 12:01:47.696  INFO [my-rest-app,,,] 1 --- [ecutor-thread-3] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler@f6e13001' of type [org.springframework.security.oauth2.provider.expression.OAuth2MethodSecurityExpressionHandler] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-09-01 12:01:47.699  INFO [my-rest-app,,,] 1 --- [ecutor-thread-3] trationDelegate$BeanPostProcessorChecker : Bean 'methodSecurityConfig' of type [com.aireuropa.microservices.arch.commons.oauth2.MethodSecurityConfig$$EnhancerBySpringCGLIB$$86bd3af3] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-09-01 12:01:47.723  INFO [my-rest-app,,,] 1 --- [ecutor-thread-3] trationDelegate$BeanPostProcessorChecker : Bean 'methodSecurityMetadataSource' of type [org.springframework.security.access.method.DelegatingMethodSecurityMetadataSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-09-01 12:01:47.738  INFO [my-rest-app,,,] 1 --- [ecutor-thread-3] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-09-01 12:01:47.808  INFO [my-rest-app,,,] 1 --- [ecutor-thread-3] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.sleuth.instrument.web.client.TraceWebClientAutoConfiguration$TraceOAuthConfiguration' of type [org.springframework.cloud.sleuth.instrument.web.client.TraceWebClientAutoConfiguration$TraceOAuthConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[AUDIT   ] CWWKT0016I: Web application available (default_host): http://f1643afc0bcc:8080/
2020-09-01 12:01:48.472 DEBUG [my-rest-app,,,] 1 --- [ecutor-thread-8] o.s.web.context.ContextLoader            : Published root WebApplicationContext as ServletContext attribute with name [org.springframework.web.context.WebApplicationContext.ROOT]
2020-09-01 12:01:48.473  INFO [my-rest-app,,,] 1 --- [ecutor-thread-8] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 4992 ms
2020-09-01 12:01:48.697  WARN [my-rest-app,,,] 1 --- [ecutor-thread-8] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
2020-09-01 12:01:48.697  INFO [my-rest-app,,,] 1 --- [ecutor-thread-8] 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.
2020-09-01 12:01:48.724  INFO [my-rest-app,,,] 1 --- [ecutor-thread-8] c.netflix.config.DynamicPropertyFactory  : DynamicPropertyFactory is initialized with configuration sources: com.netflix.config.ConcurrentCompositeConfiguration@5f8fc8d0
2020-09-01 12:01:49.032  WARN [my-rest-app,,,] 1 --- [ecutor-thread-8] com.zaxxer.hikari.HikariConfig           : HikariPool-1 - maxLifetime is less than 30000ms, setting to default 1800000ms.
2020-09-01 12:01:49.033  WARN [my-rest-app,,,] 1 --- [ecutor-thread-8] com.zaxxer.hikari.HikariConfig           : HikariPool-1 - idleTimeout has been set but has no effect because the pool is operating as a fixed size pool.
2020-09-01 12:01:49.035  INFO [my-rest-app,,,] 1 --- [ecutor-thread-8] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2020-09-01 12:01:49.241  INFO [my-rest-app,,,] 1 --- [ecutor-thread-8] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2020-09-01 12:01:49.311  WARN [my-rest-app,,,] 1 --- [ecutor-thread-8] com.zaxxer.hikari.HikariConfig           : HikariPool-2 - maxLifetime is less than 30000ms, setting to default 1800000ms.
2020-09-01 12:01:49.312  WARN [my-rest-app,,,] 1 --- [ecutor-thread-8] com.zaxxer.hikari.HikariConfig           : HikariPool-2 - idleTimeout has been set but has no effect because the pool is operating as a fixed size pool.
2020-09-01 12:01:49.313  INFO [my-rest-app,,,] 1 --- [ecutor-thread-8] com.zaxxer.hikari.HikariDataSource       : HikariPool-2 - Starting...
2020-09-01 12:01:50.644 ERROR [my-rest-app,,,] 1 --- [ecutor-thread-8] com.zaxxer.hikari.pool.HikariPool        : HikariPool-2 - Exception during pool initialization.

java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1
ORA-01882: timezone region not found

The property timezone is declared in a yaml in consul KV file.

We are running this app with the following env vars:

        SPRING_CLOUD_CONSUL_HOST="${attr.unique.hostname}"
        SPRING_CLOUD_CONSUL_CONFIG_ENABLED="true"
        SPRING_CLOUD_CONSUL_SCHEME="https"
        SPRING_CLOUD_CONSUL_SSL_KEY-STORE-PATH="/opt/consul/ssl/keystore-apps.jks"
        SPRING_CLOUD_CONSUL_SSL_KEY-STORE-PASS="XXXXX"
        SPRING_CLOUD_VAULT_ENABLED="true"
        SPRING_CLOUD_VAULT_HOST="${attr.unique.hostname}"
        SPRING_CLOUD_VAULT_TOKEN="${VAULT_TOKEN}"
        SPRING_CLOUD_VAULT_CONFIG_ENABLED="true"
        SPRING_CLOUD_VAULT_SCHEME="https"
        SPRING_CLOUD_VAULT_SSL_KEY-STORE="file:/opt/consul/ssl/keystore-apps.jks"
        SPRING_CLOUD_VAULT_SSL_KEY-STORE-PASSWORD="XXXXX"
        SPRING_CLOUD_VAULT_SSL_TRUST-STORE="file:/opt/consul/ssl/keystore-apps.jks"
        SPRING_CLOUD_VAULT_SSL_TRUST-STORE-PASSWORD="XXXX"

We tried to enable in the bootstrap properties consul but the same error ocurred. If I set the wrong path for the keystore or a wrong password for consul configuration I can see an exception saying the keystore isn't valid.

This is our server.xml:

<?xml version="1.0" encoding="UTF-8"?>
<server description="Default server">

    <!-- Enable features -->
    <featureManager>
        <feature>springBoot-2.0</feature>
        <feature>servlet-4.0</feature>
        <feature>jsp-2.3</feature>
        <!-- <feature>webSocket-1.1</feature> -->
        <feature>transportSecurity-1.0</feature>
    </featureManager>

    <!-- To allow access to this server from a remote client host="*" has been added to the following element -->
    <httpEndpoint id="defaultHttpEndpoint"
                  host="*"
                  httpPort="8080"
                  httpsPort="9443" />

</server>

And the image used is "openliberty/open-liberty:kernel-java11-openj9-ubi"

Could you help me with this?

anjumfatima90 commented 4 years ago

Hello, apologies for the delay. I tested a sample by running it in my local wlp and it worked fine. Although I couldn't test in the docker. Could you please try running the application in the local wlp and see whether you see the same error?