freelec-springboot2-webservice icon indicating copy to clipboard operation
freelec-springboot2-webservice copied to clipboard

[오류] p.184 구글 로그인 - 로그인이 성공되지않고 로그인페이지가 반복적으로 떠요

Open chanwooo opened this issue 2 years ago • 1 comments


자답 : swagger를 추가했더니 생긴 문제였습니다..

어떤 오류인가요?

오류설명:

jdk 11 springboot 2.7.3 sb 2.7이상에서 WebSecurityConfigurerAdapter가 deprecated 되었지만.. 일단 권한부분은 잘 동작하는듯해서 이것과는 상관 없는 문제라고 생각하고있어요.

로그인이 성공되지않고 구글 로그인페이지가 반복적으로 떠요. db를 확인해보니 user는 insert가 잘 된 상황. 로그를 따라가다보니 CustomOAuth2UserService 클래스의 httpSession.setAttribute 가 있는 라인(line 43)에서 에러가 발생해요.

38, 41, 44라인의 print는 debug를 위해 추가해봤는데. 38,41라인의 print는 잘 동작해요.

user = 김누누
sessionUser = 김누누
2022-09-01 05:11:21.421 ERROR 26172 --- [nio-8080-exec-6] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception

java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.

프로젝트 주소

  • Github URL: https://github.com/chanwooo/jojoldu-springboot

오류 로그

image

image

chanwooo avatar Aug 31 '22 20:08 chanwooo

자답입니다.. 맘대로 추가해봤던 swagger와 뭔가 문제가 있었던거같아요. 혹시?하고 swagger의존성 삭제하니까 정상동작하네요.. 일단은 스웨거를 지우고 동작하는걸 확인했는데 스프링시큐리티가 붙어있어도 스웨거를 붙이고싶은 상황이 분명 필요할텐데 이럴땐 어떻게해야하지? 라는 의문점과 스웨거가 왜 세션에 값을 넣는걸 안되게할까 라는 의문점이 남네요

chanwooo avatar Sep 01 '22 19:09 chanwooo