question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OKTA_CLIENT_TOKEN env var prevents Spring Boot app from starting in Docker

See original GitHub issue

While I’m able to specify these environment variables:

  • OKTA_CLIENT_ORGURL
  • OKTA_CLIENT_PROXY_HOST
  • OKTA_CLIENT_PROXY_PORT
  • OKTA_OAUTH2_AUDIENCE

as soon as I specify OKTA_CLIENT_TOKEN the app fails to start in Docker–here’s the log:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.3.4.RELEASE)
2020-11-17 03:06:52,090 (main:[]) INFO  [***] Starting *** v2020.12.0-SNAPSHOT on 5bdff47b76-rkdrd with PID 29 (/apps/apache-tomcat/web/WEB-INF/classes started by ebizrt in /apps/apache-tomcat)
2020-11-17 03:06:52,090 (main:[]) DEBUG [***] Running with Spring Boot v2.3.4.RELEASE, Spring v5.2.9.RELEASE
2020-11-17 03:06:52,090 (main:[]) INFO  [***] The following profiles are active: ***,cloud,session-replication
2020-11-17 03:06:53,522 (main:[]) ERROR [org.springframework.boot.SpringApplication] Application run failed java.lang.IllegalStateException: Error processing condition on com.okta.spring.boot.sdk.OktaSdkConfig.oktaSdkClientCredentials
	at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:60)
	at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:108)
	at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:184)
	at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:144)
	at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:120)
	at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:331)
	at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:236)
	at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:280)
	at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:96)
2020-11-17 03:06:53,527 (main:[]) WARN  [org.springframework.boot.SpringApplication] Unable to close ApplicationContext java.lang.IllegalStateException: Failed to introspect Class [com.okta.spring.boot.sdk.OktaSdkConfig] from ClassLoader [ParallelWebappClassLoader
  context: ROOT
  delegate: false
----------> Parent Classloader:
java.net.URLClassLoader@5a8806ef
]
	at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:481)
	at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:358)
	at org.springframework.util.ReflectionUtils.getUniqueDeclaredMethods(ReflectionUtils.java:414)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.lambda$getTypeForFactoryMethod$2(AbstractAutowireCapableBeanFactory.java:742)
Screen Shot 2020-11-16 at 7 55 05 PM

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
garcger-blkcommented, Dec 2, 2020

@arvindkrishnakumar-okta yes, @bdemers 2nd suggestion worked out for us (belated thanks, btw)

<dependency>
	<groupId>com.okta.spring</groupId>
	<artifactId>okta-spring-boot-starter</artifactId>
	<exclusions>
		<exclusion>
			<groupId>com.okta.spring</groupId>
			<artifactId>okta-spring-sdk</artifactId>
		</exclusion>
	</exclusions> 
</dependency>
@Configuration
public class ApiConfig {

	@Value("${okta.client.connectionTimeout:30}")
	private String connectionTimeout;

	@Value("${okta.client.orgUrl:reasonable-default}")
	private String orgUrl;

	@Value("${okta.client.proxy.port:8080}")
	private String proxyPort;

	@Value("${okta.client.proxy.host:reasonable-default}")
	private String proxyHost;

	@Value("${okta.client.token:}")
	private String token;

	@Value("${okta.client.requestTimeout:0}")
	private String requestTimeout;

	@Value("${okta.client.rateLimit.maxRetries:4}")
	private String maxRetries;

	@Bean
	public Client client() {
		return Clients.builder()
			.setClientCredentials(new TokenClientCredentials(token))
			.setConnectionTimeout(Integer.parseInt(connectionTimeout))
			.setOrgUrl(orgUrl)
			.setProxy(new Proxy(proxyHost, Integer.parseInt(proxyPort)))
			.setRetryMaxElapsed(Integer.parseInt(requestTimeout))
			.setRetryMaxAttempts(Integer.parseInt(maxRetries))
			.build();
	}
}

0reactions
arvindkrishnakumar-oktacommented, Dec 2, 2020

@garcger-blk did that help for now (until we upgrade okta-spring-boot)?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring boot app started in docker can not access environment ...
First of all: Do not write down environment related variables to Docker file, use docker-compose on target server instead and prevent future ...
Read more >
Topical Guide | Spring Boot Docker
In this guide, we aim to show you some of the choices you can make if you are faced with the prospect of...
Read more >
How to Docker with Spring Boot | Okta Developer
Start by creating a Spring Boot application using Spring Boot ... need to run source .okta.env to set these values as environment variables....
Read more >
Starting Spring Boot Application in Docker With Profile
4. Setting Profile Using Environment Variables ... Sometimes, it's not convenient to use a hard-coded profile in our Dockerfile. If we need more ......
Read more >
Kickstart Your Spring Boot Application Development | Docker
You can run your Spring Boot artifact directly within Docker containers. This is useful when you need to quickly create microservices.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found