A quick look at the DefaultTokenService shows that it is annotated with @Transactional. Spring is going to wrap it in a proxy for serving transactions - as a result, you need to interact with the class by its interface.
For your tokenService bean:
@Bean public DefaultTokenServices tokenServices() { final DefaultTokenServices defaultTokenServices = new DefaultTokenServices(); defaultTokenServices.setAccessTokenValiditySeconds(-1); defaultTokenServices.setTokenStore(tokenStore()); return defaultTokenServices; }
try changing it to this:
@Bean public AuthorizationServerTokenServices tokenServices() { final DefaultTokenServices defaultTokenServices = new DefaultTokenServices(); defaultTokenServices.setAccessTokenValiditySeconds(-1); defaultTokenServices.setTokenStore(tokenStore()); return defaultTokenServices; }
psuthe
source share