We have class with @Configuration annotation as well as @ConfigurationProperties annotation with prefix: @ConfigurationProperties(prefix = "app.key").
This class has just one field, lets say someProperty
This works well in standard spring boot with application.yml and someProperty is correctly populated
app:
key:
someProperty: someValue
But as soon as this app gets deployed as war on websphere and the property is fetched using jndi, the value of someProperty is now null.
Instead of @ConfigurationProperties and @Configuration class, now if I just use stand @Value annotation (@Value("${app.key.someProperty}")), it works well both in normal spring boot as well as websphere via jndi.
We are using Spring boot version 2.0.1.RELEASE
Comment From: wilkinsona
Combining @ConfigurationProperties and @Configuration on the same class is rather unconventional. Does the problem still occur if you move your @ConfigurationProperties out into a separate class? If it does, can you please provide a small sample that reproduces the problem so that we can investigate further?
Comment From: hviranicitco
The @ConfigurationProperties is already on a class with just getter and setter. I put @Configuration annotation so that it gets picked up by spring as a component. Now, I tried using @Component instead of @Configuration and still have the same issue.
I also tried removing @Component and tried specifying my class explicitly on @EnableConfigurationProperties in the main application. I still get exact same issue.
The github is blocked on the enterprise proxy and I am typing this on my phone. So, lite difficult for me to provide sample for reproducing the problem.
Comment From: snicoll
@hviranicitco did you get a chance to work on this sample?
Comment From: hviranicitco
I am having little difficulty in creating the sample. Github is blocked at worked by enterprise proxy and I don't have websphere at home to try the sample.
But this was very consistently reproducible.
Comment From: wilkinsona
@hviranicitco Unfortunately, we can't afford to spend time on guessing what your application looks like. If you'd like us to investigate, we're going to need to see the code that can reproduce the problem. Perhaps you can use Open Liberty?
Comment From: hviranicitco
Thanks. Appreciate you following up. I will try my best to create a sample as soon as I can.
Comment From: hviranicitco
I created a sample application, but was not able to replicate this behavior. Not sure if this happens because of any other project dependencies.
Please close this issue. Will re-open if I am able to replicate it again and have a sample.
Thanks for your time.
Comment From: mszalus
I have the very same issue at the moment, could someone help me by pointing me to a place in spring boot codebase to debug this? I don't see anything in the logs, jndi java:comp/env are reachable directly using InitialContext or using @Value annotation, @ConfigurationProperties don't work (including spring boot built in tooling).
Comment From: philwebb
@mszalus Are you able to share a sample that shows the problem?
Comment From: InnuceEAN
I know old issue, but could this have been a camel case vs snake case issue?
e.g. your field is named "oauth2RegistrationId" so the jndi path is
- "my.prefix.oauth2-registration-id" for @ConfigurationProperties ("my.prefix") and
- "oto.ciscon.oauth2RegistrationId" for @Value("oto.ciscon.oauth2RegistrationId")