Vincent F
Vincent F

Reputation: 7331

Unable to bind a Zipkin enum in Spring Boot 2

I am upgrading an application to Spring Boot 2.1.3 (from 1.5.x), and I am facing an issue at startup time. Below block can't be bound properly :

  spring:
    zipkin:
      enabled: true
      base-url: http://myZipkinServer
      sender:
        type: web

I am getting this error :

***************************
APPLICATION FAILED TO START
***************************

Description:

Failed to bind properties under 'spring.zipkin.sender.type' to org.springframework.cloud.sleuth.zipkin2.sender.ZipkinSenderProperties$SenderType:

Property: spring.zipkin.sender.type
Value: web
Origin: class path resource [application.yml]:68:13
Reason: 0

Action:

Update your application's configuration

A bit before I am getting a WARN log announcing the issue :

Exception encountered during context initialization - cancelling refresh attempt: org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'spring.zipkin.sender-org.springframework.cloud.sleuth.zipkin2.sender.ZipkinSenderProperties': Could not bind properties to 'ZipkinSenderProperties' : prefix=spring.zipkin.sender, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'spring.zipkin.sender.type' to org.springframework.cloud.sleuth.zipkin2.sender.ZipkinSenderProperties$SenderType

I am trying to follow in debug, and I end up pretty deep in Spring Boot internals in org.springframework.boot.context.properties.bind.Binder . I have a similar app with more or less same version for which it works just fine. I am trying to find a difference, compare the execution flows, but not finding anything obvious.

In IntelliJ, I get the auto-completion so I know my yaml is formatted properly : the "web" value is proposed to me.

Any idea of how to investigate this kind of issue ?

Upvotes: 0

Views: 549

Answers (1)

Vincent F
Vincent F

Reputation: 7331

Alright, so after a few hours struggling, I made some progress, and now the app starts - even though the root cause of the issue is not fully clear to me at this time. Below are my findings :

  • one strange thing I noticed : if I change the sender.type from web to rabbit, then the application starts with no error.

  • I also found this Spring Boot issue report, very similar to mine, that was pointing at a JDK bug. And indeed, upgrading from jdk1.8.0_25 to jdk1.8.0_201 .

  • Finally, I also found that if I was using jdk1.8.0_25 and wasn't providing the sender.type at all, then the app was also starting with no issue.

For some reason, in the other app that I have and that works, I am able to use jdk1.8.0_25 and sender.type: web

If anyone has a methodology to figure out this kind of issue quickly, don't hesitate to add it in the comment or edit this answer.

Upvotes: 1

Related Questions