Question

I am getting this Exception while upgrading from Spring 3.0 to 4.0

I updated the deprecated classes with this link

DefaultAnnotationHandlerMapping,AnnotationMethodHandlerAdapter with RequestMappingHandlerMapping ,RequestMappingHandlerAdapter

java.lang.ClassCastException: AuditingController$$EnhancerByCGLIB$$992fb2c8 cannot be cast to org.springframework.web.method.HandlerMethod 

at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83)

Here is beans definition

<bean name="handlerAdapter"
    class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
            <property name="messageConverters">
        <array>
            ....

           ....
        </array>
    </property>
</bean>

In my testcase calling this function.

  handlerAdapter.handle(request, response, controller);

which calls org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter

return handleInternal(request, response, (HandlerMethod) handler);

here it fails to cast the controller to HandlerMethod

Was it helpful?

Solution

Its working now. As mentioned in this link, I need to update my controller test cases to use

WebApplicationContext,MockMvc & RequestMappingHandlerAdapter 

instead of

MockHttpServletRequest, MockHttpServletResponse & HandlerAdapter.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top