1
resposta

Uso no JAVA 7 Callable

Tentei implementar na minha aplicação o Callable, mas não funcionou corretamente, segue abaixo o código e erro:

    @RequestMapping(value = "detalhe", method = RequestMethod.GET)
    public @ResponseBody
    Callable<ModelAndView> detalhe(final HttpSession session, final HttpServletRequest request, HttpServletResponse response) throws IOException, SQLException, JSONException, ParseException {
        return new Callable<ModelAndView>() {
            @Override
            public ModelAndView call() throws Exception {
                ModelAndView model = new ModelAndView("/gpr/detalhe");
                Usuario userLogado = (Usuario) session.getAttribute("userLogado");
                model.addObject("usuario", userLogado);
                model.addObject("permissao", true);                
                return model;
            }
        };
    }

ERRO: 15:42:48,734 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[/].[SpringDispatcher]] (http--127.0.0.1-8081-7) Servlet.service() for servlet SpringDispatcher threw exception: java.lang.NoSuchMethodError: controller/ExceptionHandlerController.exceptionHandler(Ljava/lang/Exception;)Lorg/springframework/http/ResponseEntity; at controller.ExceptionHandlerController.exceptionHandler(ExceptionHandlerController.java:50001) [:] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_79] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_79] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_79] at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_79] at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) [spring-web-4.2.8.RELEASE.jar:4.2.8.RELEASE] at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136) [spring-web-4.2.8.RELEASE.jar:4.2.8.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110) [spring-webmvc-4.2.8.RELEASE.jar:4.2.8.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver.doResolveHandlerMethodException(ExceptionHandlerExceptionResolver.java:367) [spring-webmvc-4.2.8.RELEASE.jar:4.2.8.RELEASE] at org.springframework.web.servlet.handler.AbstractHandlerMethodExceptionResolver.doResolveException(AbstractHandlerMethodExceptionResolver.java:59) [spring-webmvc-4.2.8.RELEASE.jar:4.2.8.RELEASE] at org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver.resolveException(AbstractHandlerExceptionResolver.java:137) [spring-webmvc-4.2.8.RELEASE.jar:4.2.8.RELEASE] at org.springframework.web.servlet.handler.HandlerExceptionResolverComposite.resolveException(HandlerExceptionResolverComposite.java:74) [spring-webmvc-4.2.8.RELEASE.jar:4.2.8.RELEASE] at org.springframework.web.servlet.DispatcherServlet.processHandlerException(DispatcherServlet.java:1185) [spring-webmvc-4.2.8.RELEASE.jar:4.2.8.RELEASE]

1 resposta

Opa,

"java.lang.NoSuchMethodError" => Essa exception geralmente vem junto de um problema de versão com alguma dependência do projeto... Eu olharia de novo cada uma das versões e compararia com o que é colocado no curso.