https://kotlinlang.org logo
Title
e

Erik Dreyer

05/26/2023, 4:23 PM
I’m trying to setup a Spring Boot (3.1.0) app with Spring security (default version for Spring Boot 3.1.0). I’m having trouble setting up a
JwtDecoder
bean due to an ambiguous constructor in a java class The error I get is:
/auth0/my-auth0-demo/auth0/src/main/kotlin/com/curbee/auth0/SecurityConfig.kt:48:7
Kotlin: None of the following functions can be called with the arguments supplied: 

public constructor DelegatingOAuth2TokenValidator<T : OAuth2Token!>(vararg tokenValidators: OAuth2TokenValidator<TypeVariable(T)!>!) defined in org.springframework.security.oauth2.core.DelegatingOAuth2TokenValidator

public constructor DelegatingOAuth2TokenValidator<T : OAuth2Token!>(tokenValidators: (Mutable)Collection<OAuth2TokenValidator<TypeVariable(T)!>!>!) defined in org.springframework.security.oauth2.core.DelegatingOAuth2TokenValidator
To help assist, the constructors for the class in error: `DelegatingOAuth2TokenValidator.java`:
public DelegatingOAuth2TokenValidator(Collection<OAuth2TokenValidator<T>> tokenValidators) {
		Assert.notNull(tokenValidators, "tokenValidators cannot be null");
		this.tokenValidators = new ArrayList<>(tokenValidators);
	}

	@SafeVarargs
	public DelegatingOAuth2TokenValidator(OAuth2TokenValidator<T>... tokenValidators) {
		this(Arrays.asList(tokenValidators));
	}
I’ve tried all kinds of combinations to try and get this to compile. e.g. •
DelegatingOAuth2TokenValidator<OAuth2TokenValidator<Jwt>>(withIssuer)
DelegatingOAuth2TokenValidator<OAuth2TokenValidator<Jwt>>(*withIssuer)
DelegatingOAuth2TokenValidator<OAuth2TokenValidator<Jwt>>(listOf(withIssuer))
DelegatingOAuth2TokenValidator<OAuth2TokenValidator<Jwt>>(*listOf(withIssuer))
DelegatingOAuth2TokenValidator<OAuth2TokenValidator<Jwt>>(java.utils.Arrays.asList(withIssuer))
I could use some help figuring how to give a hint to which consructor
I figure others using recent versions of Spring boot with kotlin may also have this issue?