Invalid JWK Set URL: null

Viewed 664

I have implemented a spring boot application with JWT and OAuth2. Private and public keys have been generated by using java keytool with jks keystore. Generated .jks file is copied and pasted into the resource folder in the spring boot application.enter image description here

@Configuration
@EnableAuthorizationServer
public class OAuth2Config extends AuthorizationServerConfigurerAdapter {

JwtAccessTokenConverter converter=new CustomTokenEnhancer();
        converter.setKeyPair(new KeyStoreKeyFactory(new ClassPathResource("jwt.jks"),"password".toCharArray()).getKeyPair("jwt"));
        return converter;

}

When I run the application then following errors are occurred

Caused by: java.lang.IllegalArgumentException: Invalid JWK Set URL: null

.

 Caused by: java.net.MalformedURLException: null
at java.base/java.net.URL.<init>(URL.java:661) ~[na:na]
at java.base/java.net.URL.<init>(URL.java:523) ~[na:na]
at java.base/java.net.URL.<init>(URL.java:470) ~[na:na]
at org.springframework.security.oauth2.provider.token.store.jwk.JwkDefinitionSource.<init>(JwkDefinitionSource.java:74) ~[spring-security-oauth2-2.3.4.RELEASE.jar:na]
... 112 common frames omitted

.

 Caused by: java.lang.NullPointerException: null
    at java.base/java.net.URL.<init>(URL.java:567) ~[na:na]
    ... 115 common frames omitted
1 Answers

In my case, it was not added to the build path implicitly that is why NullPointErexception has occurred. I have used maven as a build tool, So clean the build path and install it again manually then it is available in the build path.

  mvn clean install
Related