Build Spring Microservices and Dockerize them for Production

Matt Raible

When you see this error, look in your browser’s address bar and copy the entire URL. Paste it into a text editor so you can easily see the redirect_uri parameter that’s being passed in. Copy the value of the parameter and add it as a Login redirect URI to your app on Okta. Refresh the page and everything should work!

Varma Dandu

Thanks a lot Matt and auth works like a champ now but after this change the internal call from school-ui to school-service doesn’t happen.

Tried below:
- Exposed port:8081 from docker-compose and I can see the data
- Also tried updated okta.oauth2.redirect-uri at school-ui props with redirect uri but no change
- Nothing explains why from logs as well

Matt Raible

You might try cloning the repo and setting things up that way. Or comparing your code and versions to what’s on GitHub.

Abel Morris Ben

Hello, Matt. I have the following exception from the school-ui.

Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘springSecurityConfiguration’: Unsatisfied dependency expressed through method ‘setContentNegotationStrategy’ parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration’: Unsatisfied dependency expressed through method ‘setConfigurers’ parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘org.springframework.security.config.annotation.web.configuration.OAuth2ClientConfiguration$OAuth2ClientWebMvcSecurityConfiguration’: Unsatisfied dependency expressed through method ‘setClientRegistrationRepository’ parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘org.springframework.boot.autoconfigure.security.oauth2.client.servlet.OAuth2ClientRegistrationRepositoryConfiguration’: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘spring.security.oauth2.client-org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientProperties’: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Client id must not be empty.

Matt Raible

The error says you’re missing a client ID in your school-ui.properties. You might try comparing your code to the completed example on GitHub.

Abel Morris Ben

The school-ui.properties file is fine. Anyway, i will do as you said. Thanks

Okta Developers

Here’s a more up-to-date tutorial that shows a more recent version of Spring Boot and Spring Cloud Config. Maybe it’ll help? https://developer.okta.com/…

Abel Morris Ben

It’s okay now. Thanks so much!!