I am using spring security 4 and mybatis as an orm to the database. For authentication I am using mobile number and a generated OTP(still left to implement). I am getting a null pointer error as the AuthenticationProvider class for some reason can not communicate with the database throught the ORM.My security configuration class
My interface for user class
My class which implements the interface Remove crackling from video.
And my user details service implementation
Dark souls 1 graphics overhaul. And the stack trace
JavaGuyJavaGuy
1 Answer
I had made a stupid mistake. I needed to add the UserDetailsServicesImpl object inside the class and Autowire it, instead I declared it inside the configure. method.
JavaGuyJavaGuy
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Not the answer you're looking for? Browse other questions tagged spring-securitymybatisspring-mybatis or ask your own question.
You can encounter the following exception:org.springframework.security.authentication.InternalAuthenticationServiceException: UserDetailsService returned null, which is an interface contract violation
Userdetails Spring Security
UserDetailsService.loadUserByUsername() shouldn't return a null value as described in Javadoc.When the value is null, it should throw a UsernameNotFoundException as follows:
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
User user = userRepository.findByUsername(username);
if (user null) {
throw new UsernameNotFoundException(username);
}
return user;
}