spring-security-react-ant-design-polls-app icon indicating copy to clipboard operation
spring-security-react-ant-design-polls-app copied to clipboard

@EntityScan(basePackageClasses = {Jsr310JpaConverters.class})

Open monxarat opened this issue 6 years ago • 2 comments

Hi @callicoder When I add config @EntityScan(basePackageClasses = {Jsr310JpaConverters.class}) to Application class.

and add method init(). The bellow error has occurred. And not started Tomcat.

@PostConstruct
void init() {
        TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
    }

org.springframework.beans.factory.UnsatisfiedDependencyException: 
Error creating bean with name 'securityConfiguration': Unsatisfied dependency expressed through field 
'userDetailsService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: 
Error creating bean with name 'userDetailsService': Unsatisfied dependency expressed through field 'userService'; 
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 
'userService': Unsatisfied dependency expressed through field 'userRepository'; 
nested exception is org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'userRepository': Invocation of init method failed; 
nested exception is java.lang.IllegalArgumentException: Not a managed type: class example.database.entry.User

monxarat avatar Nov 25 '18 23:11 monxarat

I have solved. Because I forgot to add Application.class to @EntityScan. When login perform error has occurred.

Can't cast String to UserPrincipal in the method generaterToken();

monxarat avatar Nov 26 '18 01:11 monxarat

When I have performed signin, the bellow error has occurred.

org.springframework.security.authentication.BadCredentialsException: Bad credentials
	at org.springframework.security.authentication.dao.DaoAuthenticationProvider.additionalAuthenticationChecks(DaoAuthenticationProvider.java:89) ~[spring-security-core-5.0.5.RELEASE.jar:5.0.5.RELEASE]
	at org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider.authenticate(AbstractUserDetailsAuthenticationProvider.java:166) ~[spring-security-core-5.0.5.RELEASE.jar:5.0.5.RELEASE]
	at org.springframework.security.authentication.ProviderManager.authenticate(ProviderManager.java:174) ~[spring-security-core-5.0.5.RELEASE.jar:5.0.5.RELEASE]
	at org.springframework.security.authentication.ProviderManager.authenticate(ProviderManager.java:199) ~[spring-security-core-5.0.5.RELEASE.jar:5.0.5.RELEASE]
	at org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter$AuthenticationManagerDelegator.authenticate(WebSecurityConfigurerAdapter.java:512) ~[spring-security-config-5.0.5.RELEASE.jar:5.0.5.RELEASE]
	at example.service.impl.LoginServiceImpl.login(LoginServiceImpl.java:69) ~[classes/:na]
	at example.sso.auth.LoginController.authenticateUser(LoginController.java:63) ~[classes/:na]

DaoAuthenticationProvider.java:89

if (!passwordEncoder.matches(presentedPassword, userDetails.getPassword())) {
			logger.debug("Authentication failed: password does not match stored value");

			throw new BadCredentialsException(messages.getMessage(
					"AbstractUserDetailsAuthenticationProvider.badCredentials",
					"Bad credentials"));
		}

monxarat avatar Nov 27 '18 22:11 monxarat