NestedServletException: Handler dispatch failed

pickylemon·2024년 5월 19일

Exception 모음

목록 보기
16/31

Failed to complete request: org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.Error: Unresolved compilation problem:
The method join(HashMap<String,String>, HttpServletRequest) in the type JoinService is not applicable for the arguments (HashMap<String,String>)
org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: 경로 [/pf]의 컨텍스트 내의 서블릿 [pf]을(를) 위한 Servlet.service() 호출이, 근본 원인(root cause)과 함께, 예외 [Handler dispatch failed; nested exception is java.lang.Error: Unresolved compilation problem:
The method join(HashMap<String,String>, HttpServletRequest) in the type JoinService is not applicable for the arguments (HashMap<String,String>)
]을(를) 발생시켰습니다.
java.lang.Error: Unresolved compilation problem:
The method join(HashMap<String,String>, HttpServletRequest) in the type JoinService is not applicable for the arguments (HashMap<String,String>)

상황

메일 인증 주소를 구성할 때 contextPath를 하드코딩이 아닌, 동적으로 가져와야 해서, 메서드의 매개변수에 HttpServletRequest를 추가함
(HttpServletRequest의 getContextPath() 메서드를 쓰기 위해)

원인 및 해결

순간 Service와 Controller클래스를 착각함.
내가 HttpServletRequest를 매개변수로 추가한 메서드는 Controller메서드가 아닌 Service메서드였다.
Controller 쪽에서 Service로 HttpServletRequest타입의 인자를 넘겨주지 않았으므로 Service에서 해당 매개변수를 받을 수 없는게 당연하다. (Spring의 Controller에서는 아래와 같이 다양한 인자를 받을 수 있지만, Service는 일반 클래스라서 Service를 호출한 쪽에서 넘겨주는 인자만 받을 수 있다.)

해결 : Controller에서 contextPath를 구해서 Service에 넘겨주는 방식으로 수정.

참고) Spring Controller에서 받을 수 있는 Arguments
https://docs.spring.io/spring-framework/reference/web/webmvc/mvc-controller/ann-methods/arguments.html

profile
안녕하세요

0개의 댓글