Trouble Shooting

[Trouble Shooting] 프로젝트 [짤태식이 돌아왔다!]

오두기밥 2022. 6. 26. 23:03

1. 발생 오류 및 해결방법

1. QueryDSL을 사용하여 일대 다 연관 관계 두 개 컬럼 패치시 오류 발생

 이슈 내용(에러코드) :  `org.hibernate.loader.MultipleBagFetchException`
 해결 방법:  `List`는 복수 개의 fetch 가 안됨으로 컬럼 타입 `Set`으로 변경 

 2. LocalDateTime, json으로 변환 실패 오류
 이슈 내용(에러코드)** :  `InvalidDefinitionException: Java 8 date/time type java.time.LocalDateTime...` 
 해결 방법** :  java 8 의 date/time은  POJO로 serialize가 될수 없기에 문자열로 변환 response
 
 3. LocalDateTime, json으로 변환 실패 오류
 이슈 내용(에러코드):  `InvalidDefinitionException: Java 8 date/time type java.time.LocalDateTime...`
 해결 방법:  java 8 의 date/time은  Json으로 변환이 되지 않아 문자열로 변환 후  response

 4. Cors 에러
 이슈 내용: react 에서 ec2 서버로 요청 시 cors에러 발생
 해결 방법: spring security Cors 설정에 s3 엔드 포인드 `AllowedOrigin` 추가
 
5. DTO 형식의 반환형에 `fetchJoin()` 시 발생
이슈 내용(에러 코드): org.hibernate.QueryException: query specified join fetching, but the owner of the fetched association was not present in the select list**
해결 방법 : `fetchjoin()` 제거

 6. 유효하지 않은 토큰 시 강제 로그아웃 처리 시, “다시 로그인 해주세요” 메시지출력 안됨
 이슈 내용(에러 코드):** `java.lang.IllegalStateException: getWriter() has already been called for this response`
 해결 방법** : exception을 다르게 해서 `response.getWriter()` 겹치지 않게 로직 변경