모니터링 배치를 만들 일이 생겼습니다.
미발송 데이터를 읽어 슬랙으로 알림 처리를 하는 배치인데,
리더를 구현 후 JUnit으로 테스트를 시도했더니 본 적 없던 에러가 발생했습니다.
늘 쓰던 JdbcPagingItemReader였는데...
레퍼런스의 예제와도 동일한데 아래와 같이 에러가 발생했습니다.
java.lang.ClassCastException: com.sun.proxy.$Proxy254 cannot be cast to org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader
java.lang.ClassCastException: com.sun.proxy.$Proxy254 cannot be cast to org.springframework.batch.item.database.JdbcPagingItemReader
ClassCastException이 발생하여 spring에서 제공하는 클래스를 사용했는데 왜일까...
JdbcCursorItemReader, RepositoryItemReader, JpaPaigngReader 등을 사용해도 같은 에러가 발생했습니다.
분석을 위해 상속받은 클래스를 타고 타고 들어갔습니다.
ItemStrem을 구현한 것을 확인할 수 있었습니다.
그래서 ItemStreamReader로 구현하여 해결할 수 있었습니다.
p.s ItemStreamReader도 결국 ItemReader를 상속받기 때문에 ItemReader로도 구현할 수 있습니다.
'- Spring' 카테고리의 다른 글
[Spring Hateoas 1.2] RepresentationModel 테스트 (0) | 2020.08.24 |
---|---|
[Spring Hateoas 1.2] 소개 및 프로젝트 설정 (0) | 2020.08.21 |
[Spring Batch] If you want to run this job again, change the parameters. (0) | 2020.07.17 |
[JPA] Embeddable, Embedded (0) | 2020.07.16 |
[JUnit 5] @TestMethodOrder (0) | 2020.06.25 |