• 카테고리

    질문 & 답변
  • 세부 분야

    백엔드

  • 해결 여부

    미해결

apiJob 실행시IllegalArgumentException 발생

22.07.31 10:53 작성 조회수 913

0

안녕하세요 강의 잘 듣고 있습니다.
 
실습 프로젝트 코드 작성해서 apiJob 실행했더니 아래와 같은 에러가 발생합니다.
 
해당문제는 sprinb batch version으로 인한 문제인걸로 보이는데 (물론 오타로 인한 에러를 찾지 못하고 있을수도 있습니다) 구글링과 에러내용에서 권장하는 ObjecpMapper를 이용해도 동일한 에러가 발생해서 해결방법을 알려주시면 감사하겠습니다.
 
# 이슈
https://github.com/spring-projects/spring-batch/issues/3732
 
# Source Git Repository
https://github.com/goodbyeyo/spring-batch
 
 
# 에러내용
java.lang.IllegalArgumentException: Unable to deserialize the execution context
 
Caused by: com.fasterxml.jackson.databind.JsonMappingException: The class with study.batch.batchService.domain.ProductVO and name of study.batch.batchService.domain.ProductVO is not trusted. If you believe this class is safe to deserialize, you can add it to the base set of trusted classes at construction time or provide an explicit mapping using Jackson annotations or a custom ObjectMapper. If the serialization is only done by a trusted source, you can also enable default typing. (through reference chain: java.util.HashMap["product"])
 
Caused by: java.lang.IllegalArgumentException: The class with study.batch.batchService.domain.ProductVO and name of study.batch.batchService.domain.ProductVO is not trusted. If you believe this class is safe to deserialize, you can add it to the base set of trusted classes at construction time or provide an explicit mapping using Jackson annotations or a custom ObjectMapper. If the serialization is only done by a trusted source, you can also enable default typing.
 
 
 

답변 1

답변을 작성해보세요.

0

일단 코드를 받아서 실행 시켜 보면 오류가 나는데 

ApiStepConfiguration 의

public ItemReader<ProductVO> itemReader(@Value("#{stepExecutionContext['product']}") 
ProductVO productVO) throws Exception {

에 @Bean 과 @StepScope 가 빠져 있어 추가 하니 기동은 되었습니다.

@StepScope
@Bean
public ItemReader<ProductVO> itemReader(@Value("#{stepExecutionContext['product']}") 
                                            ProductVO productVO) throws Exception

그리고 DB 에도 값이 정상적으로 입력이 되어 있습니다.

제가 실행해보니 질문하신 에러가 발생하지는 않습니다.

에러 재현을 위해서는 좀 더 자세한 상황에 대한 설명이 필요할 것 같습니다.