authenticationManager threw StackOverFlow
My end point http://localhost:8080/auth/login doesn't work, it always throws StackOverFlow.
java.lang.StackOverflowError: null
at org.springframework.aop.support.AopUtils.isEqualsMethod(AopUtils.java:166) ~[spring-aop-6.2.2.jar:6.2.2]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:175) ~[spring-aop-6.2.2.jar:6.2.2]
at jdk.proxy2/jdk.proxy2.$Proxy145.authenticate(Unknown Source) ~[na:na]
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[na:na]
30 Replies
⌛
This post has been reserved for your question.
Hey @Tomás! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
the image with the code isnt visible at all
just paste it here
@RestController
@RequestMapping(value = "/auth")
This message has been formatted automatically. You can disable this using
/preferences
.the imports package ecomerce.api.controllers;
import ecomerce.api.domain.DTOs.AuthDTO;
import ecomerce.api.domain.DTOs.LoginResponseDTO;
import ecomerce.api.domain.DTOs.RegisterDTO;
import ecomerce.api.domain.User;
import ecomerce.api.infra.security.TokenService;
import ecomerce.api.repositories.UserRepository;
import jakarta.validation.Valid;
import org.springframework.http.ResponseEntity;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
show auth manager
@Configuration
@EnableWebSecurity
This message has been formatted automatically. You can disable this using
/preferences
.It's from import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
AuthenticationManager (spring-security-docs 6.4.2 API)
declaration: package: org.springframework.security.authentication, interface: AuthenticationManager
try to add static to the authentication manager bean and see if it works
ok
same error
show how u changed the code
private static AuthenticationManager authenticationManager;
no
not here
here
yeah, same
did you delete the static from the private field
yes
GitHub
GitHub - tomas-barros1/e-commerce-api-spring: Esta é uma API que si...
Esta é uma API que simula uma espécie de e-commerce desenvolvida com Spring Boot, MySQL e Docker. A API permite gerenciar produtos, categorias, usuários, pedidos e pagamentos . - tomas-barros1/e-co...
interesting
the register end point works
do you have more than one authentication provider
or authentication configuration
no
try this
**
APPLICATION FAILED TO START
**
Description:
Field userDetailsService in ecomerce.api.infra.security.SecurityConfigurations required a bean of type 'org.springframework.security.core.userdetails.UserDetailsService' that could not be found.
Action:
Consider defining a bean of type 'org.springframework.security.core.userdetails.UserDetailsService' in your configuration.
you need to define user details service bean
for testing purposes do this
User details service class is provided by spring
try this
i dont have any erros anymore when i try to login
😱
crazy right
you have to define your own user details service though
cuz the code i pasted is for testing
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.