I am building a set of restful services using Spring MVC version 4.1.7 trying to use @RestController for the controller so I shouldn't need @ResponseBody right? When I include @ResponseBody the request returns true. The project builds fine but when I deploy it to tomcat try to hit my endpoint it throws an exception that I shouldn't expect with 4.1.7
The controller:
@RestController
public class IsAliveController {
@RequestMapping(value = "/isalive", method = RequestMethod.GET)
public Boolean isAlive() {
return true;
}
}
The error (Why the 3.2.9.RELEASE version?):
java.lang.IllegalArgumentException: Unknown return value type [java.lang.Boolean]
at org.springframework.util.Assert.notNull(Assert.java:112) ~[spring-core-3.2.9.RELEASE.jar:3.2.9.RELEASE]
at org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue(HandlerMethodReturnValueHandlerComposite.java:68) ~[spring-web-3.2.9.RELEASE.jar:3.2.9.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:122) ~[spring-webmvc-3.2.9.RELEASE.jar:3.2.9.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745) ~[spring-webmvc-3.2.9.RELEASE.jar:3.2.9.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:685) ~[spring-webmvc-3.2.9.RELEASE.jar:3.2.9.RELEASE]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80) ~[spring-webmvc-3.2.9.RELEASE.jar:3.2.9.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:919) ~[spring-webmvc-3.2.9.RELEASE.jar:3.2.9.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:851) ~[spring-webmvc-3.2.9.RELEASE.jar:3.2.9.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:953) [spring-webmvc-3.2.9.RELEASE.jar:3.2.9.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:844) [spring-webmvc-3.2.9.RELEASE.jar:3.2.9.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617) [servlet-api.jar:na]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:829) [spring-webmvc-3.2.9.RELEASE.jar:3.2.9.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) [servlet-api.jar:na]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) [catalina.jar:6.0.26]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [catalina.jar:6.0.26]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) [catalina.jar:6.0.26]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) [catalina.jar:6.0.26]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) [catalina.jar:6.0.26]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [catalina.jar:6.0.26]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [catalina.jar:6.0.26]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) [catalina.jar:6.0.26]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852) [tomcat-coyote.jar:6.0.26]
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) [tomcat-coyote.jar:6.0.26]
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:396) [tomcat-coyote.jar:6.0.26]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.8.0_102]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.8.0_102]
at java.lang.Thread.run(Unknown Source) [na:1.8.0_102]
The mvn dependency:tree for this module:
+- org.springframework:spring-core:jar:4.1.7.RELEASE:compile
+- org.springframework:spring-web:jar:4.1.7.RELEASE:compile
| \- org.springframework:spring-context:jar:4.1.7.RELEASE:compile
+- org.springframework:spring-webmvc:jar:4.1.7.RELEASE:compile
| \- org.springframework:spring-expression:jar:4.1.7.RELEASE:compile
+- org.springframework:spring-beans:jar:4.1.7.RELEASE:compile
+- org.springframework.ws:spring-ws-security:jar:2.1.4.RELEASE:compile
| +- org.springframework.ws:spring-ws-core:jar:2.1.4.RELEASE:compile
| | +- org.springframework.ws:spring-xml:jar:2.1.4.RELEASE:compile
| | +- org.springframework:spring-oxm:jar:4.1.7.RELEASE:compile
| | \- wsdl4j:wsdl4j:jar:1.6.1:compile
| +- org.springframework:spring-tx:jar:4.1.7.RELEASE:compile
| +- org.apache.ws.security:wss4j:jar:1.6.14:compile
| | +- org.apache.santuario:xmlsec:jar:1.5.6:compile
| | \- org.opensaml:opensaml:jar:2.5.1-1:compile
| | \- org.opensaml:openws:jar:1.4.2-1:compile
| | \- org.opensaml:xmltooling:jar:1.3.2-1:compile
| +- org.springframework.security:spring-security-core:jar:3.1.0.RELEASE:compile
| | \- org.springframework.security:spring-security-crypto:jar:3.1.0.RELEASE:compile
| \- javax.xml.stream:stax-api:jar:1.0-2:compile
+- org.springframework:spring-aop:jar:4.1.7.RELEASE:compile
| \- aopalliance:aopalliance:jar:1.0:compile
+- javax.validation:validation-api:jar:1.1.0.Final:compile
What could I be missing here?
--Update-- I deployed the war to three different tomcat containers 2/3 worked correctly it is just the one Tomcat6 container with the problem. Still baffles me as I am not sure which files on tomcat would have caused such a problem
Embarrassingly enough, the solution for my problem ended up being a restart for the tomcat container. For what ever reason the war was not auto-deploying like the other systems and was holding on to an old directory for the services.