Feign 타 임 스 오류 해결 java.lang.IllegalArgument 예외:Body parameter 2 was null


1.잘못된 정보
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is com.netflix.hystrix.exception.HystrixRuntimeException: WebArticleService#page(int,int,TbPostsPost) failed and no fallback available.
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:982) ~[spring-webmvc-5.0.8.RELEASE.jar:5.0.8.RELEASE]
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:866) ~[spring-webmvc-5.0.8.RELEASE.jar:5.0.8.RELEASE]
	......
Caused by: com.netflix.hystrix.exception.HystrixRuntimeException: WebArticleService#page(int,int,TbPostsPost) failed and no fallback available.
	at com.netflix.hystrix.AbstractCommand$22.call(AbstractCommand.java:819) ~[hystrix-core-1.5.12.jar:1.5.12]
	at com.netflix.hystrix.AbstractCommand$22.call(AbstractCommand.java:804) ~[hystrix-core-1.5.12.jar:1.5.12]
	at rx.internal.operators.OperatorOnErrorResumeNextViaFunction$4.onError(OperatorOnErrorResumeNextViaFunction.java:140) ~[rxjava-1.3.8.jar:1.3.8]
	at rx.internal.operators.OnSubscribeDoOnEach$DoOnEachSubscriber.onError(OnSubscribeDoOnEach.java:87) ~[rxjava-1.3.8.jar:1.3.8]
	at rx.internal.operators.OnSubscribeDoOnEach$DoOnEachSubscriber.onError(OnSubscribeDoOnEach.java:87) ~[rxjava-1.3.8.jar:1.3.8]
	at com.netflix.hystrix.AbstractCommand$DeprecatedOnFallbackHookApplication$1.onError(AbstractCommand.java:1472) ~[hystrix-core-1.5.12.jar:1.5.12]
	at com.netflix.hystrix.AbstractCommand$FallbackHookApplication$1.onError(AbstractCommand.java:1397) ~[hystrix-core-1.5.12.jar:1.5.12]
	......
Caused by: java.lang.IllegalArgumentException: Body parameter 2 was null
	at feign.Util.checkArgument(Util.java:102) ~[feign-core-9.5.1.jar:na]
	at feign.ReflectiveFeign$BuildEncodedTemplateFromArgs.resolve(ReflectiveFeign.java:343) ~[feign-core-9.5.1.jar:na]
	at feign.ReflectiveFeign$BuildTemplateByResolvingArgs.create(ReflectiveFeign.java:213) ~[feign-core-9.5.1.jar:na]
	at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:72) ~[feign-core-9.5.1.jar:na]
	at feign.hystrix.HystrixInvocationHandler$1.run(HystrixInvocationHandler.java:108) ~[feign-hystrix-9.5.1.jar:na]
	at com.netflix.hystrix.HystrixCommand$2.call(HystrixCommand.java:302) ~[hystrix-core-1.5.12.jar:1.5.12]
	at com.netflix.hystrix.HystrixCommand$2.call(HystrixCommand.java:298) ~[hystrix-core-1.5.12.jar:1.5.12]
	at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:46) ~[rxjava-1.3.8.jar:1.3.8]
	......

2.오류 코드
@GetMapping(value = "v1/articles/{pageNum}/{pageSize}")
    String page(@PathVariable(value = "pageNum") int pageNum,
                @PathVariable(value = "pageSize") int pageSize,
                @RequestBody(required = false) TbPostsPost tbPostsPost);

디 버 깅 을 통 해 이 때 경로 파라미터 pageNum,pageSize 가 값 을 가 져 올 수 없어 서 오류 가 발생 했 습 니 다.코드 를 다음 으로 변경 합 니 다.
 @GetMapping(value = "v1/articles/{pageNum}/{pageSize}")
    String page(@PathVariable(value = "pageNum",required = false) int pageNum,
                @PathVariable(value = "pageSize",required = false) int pageSize,
                @RequestBody(required = false) TbPostsPost tbPostsPost);

문제 가 여전히 해결 되 지 않 은 것 을 발견 하 다.
3.정확 한 코드
 마지막 으로@RequestBody 를@RequestParam 으로 바 꾸 고 문 제 는 최종 적 으로 해결 되 었 습 니 다.
    @GetMapping(value = "v1/articles/{pageNum}/{pageSize}")
    String page(@PathVariable(value = "pageNum") int pageNum,
                @PathVariable(value = "pageSize") int pageSize,
                @RequestParam(required = false) TbPostsPost tbPostsPost);

좋은 웹페이지 즐겨찾기