@JsonFilter 적용 후 오류 발생했을 때 response에 {} 가 포함되어 리턴됩니다.
585
작성한 질문수 1
안녕하세요,
강의 09:35 지점 처럼 @JsonFilter("UserInfo") 적용 후 SimpleBeanPropertyFilter와 FilterProvider를 적용하지 않은 UserController에서 호출했을 때 아래 오류가 발생하는데
Type definition error: [simple type, class com.study.myrestfulwebservice.user.User]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot resolve PropertyFilter with id 'UserInfo'; no FilterProvider configured
포스트맨에서 응답 body를 확인해보면 아래 스샷처럼 빈 오브젝트가 포함되어서 리턴됩니다. 강제로 throw new RuntimeException을 발생시키면 빈 오브젝트 없이 정상적으로 ErrorResponse 객체에 대해서만 출력됩니다. 빈 오브젝트가 왜 포함되서 리턴되는지 원인을 알 수 없어 문의드립니다 ㅠ_ㅠ
답변 1
0
안녕하세요, 이도원입니다.
문의하신 내용에서처럼 EntityModel 객체를 정상적으로 반환할 때는, 문제가 없지만, 오류가 발생한 경우(JsonFilter에 의한 Filter객체를 지정하지 않을 때와 같은)에는 ExceptionResponse 객체를 생성해서 반환하게 됩니다.
<EntityModel/>
<ExceptionResponse>
<timestamp>2022-04-16T04:31:23.475+00:00</timestamp>
<message>Type definition error: [simple type, class com.example.myrestfulservices.user.User]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot resolve PropertyFilter with id 'UserInfo'; no FilterProvider configured (through reference chain: org.springframework.hateoas.EntityModel["content"])</message>
<details>uri=/users/3</details>
</ExceptionResponse>
크롬 웹브라우저의 개발자도구 > 네트워크 탭을 실행한 다음 ,해당 URI를 호출하면 아래와 같은 응답 메시지를 확인하실 수 있습니다. 정상적인 상태라면 EntityModel 객체만을 반환할 것이며, 오류가 발생했다면, 빈 EntityModel 객체와 ExceptionResponse 객체 2개가 함께 반환됩니다. RuntimeException을 발생 시켰을 경우에는 ExceptionResponse 객체가 생성된 것이 아니니 때문에, 빈 EntityModel 객체 1개만 반환 됩니다.

감사합니다.
JPA
0
71
1
jpa dependency를 추가하고 SecurityConfig클래스에서 오류가 납니다.
0
84
1
웹 브라우저 400 bad request
0
87
1
@Size는 되는데 @Past는 안 됩니다.
0
78
1
pdf 자료는 없나요?
0
95
2
locale 정보가 null 이면 무조건 messages_ko.properties이 호출 되는 문제
0
103
2
Swagger 강의, Unable to infer base url 이거 뜨시는 분들 도움되시라고
0
137
1
강의에서나온 화면 피피티
0
169
1
HelloWorldBean 관련 에러
0
194
2
Swagger API 3.x 오류..
0
231
1
java: variable message not initialized in the default constructor 에러는 어찌하면 좋을까요?
1
295
1
현재 GIT에 올리신 소스를 실행해봤습니다.
0
203
2
고양이 소리가 귀엽네요 !!
0
150
2
git에서 소스받고 실습중인데
0
129
1
post가 안되요
0
119
1
한국어 같은 경우 언어코드인 messages_ko.properties 로 생성하는게 더 좋지 않나요?
0
177
2
리턴타입으로서 EntityModel<User> 와 ResponseEntity질문
0
113
1
예외처리쪽 관련 질문있습니다.
0
166
2
엔티티가 바로 응답으로 나가도 되나요??
0
241
2
안녕하세여 Cannot invoke "co.kr.joneconsulting.resfulservice.repository.PostRepository.save(Object)" because "this.postRepository" is null
0
152
2
사용자 등록하고 나서 H2 에서 보면 신규 사용자의 password, ssn 이 null 로 되어 있습니다.
0
146
2
ApplictionContext 질문
0
199
2
롬북이 안먹히는것같아요
0
162
1
인텔리제이에서스프링부트 파일 실행하면
0
244
1





