리나 Dev토리

[트슈] IllegalStateException: Cannot call sendError() after the response has been committed 본문

SpringBoot 개인플젝(TodayMaker)

[트슈] IllegalStateException: Cannot call sendError() after the response has been committed

리나lina 2023. 4. 6. 19:52

에러

할일들 목록에서 

몇개를 선택하고 오늘날짜로 추가하고 나서

 

오늘 날짜 밑에

할일 목록을 뿌려주는 데서

 

IllegalStateException: Cannot call sendError() after the response has been committed

StackOverflowError: null

 

위 에러가 나왔다.

 

원인

할일들 객체를 json으로 바꾸는 과정에서

연관관계 있는 todouser가 

 

계속 서로를 참조하면서 재귀함수가 계속적으로 발생하여

stack 공간이 부족해져서 나온 에러이다.

 

해결 방법 

@ManyToOne 연관관계가 매핑 되는 필드인

User 와 Category 에 

@JsonIgnore를 붙여주면 순환 참조가 끊어지게 된다.

 

 

 

참고: https://zoetechlog.tistory.com/97

 

Comments