aspose file tools*
The moose likes Spring and the fly likes java.lang.ClassCastException: ParameterizableViewController cannot be cast to  HandlerMethod Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "java.lang.ClassCastException: ParameterizableViewController cannot be cast to  HandlerMethod" Watch "java.lang.ClassCastException: ParameterizableViewController cannot be cast to  HandlerMethod" New topic
Author

java.lang.ClassCastException: ParameterizableViewController cannot be cast to HandlerMethod

monicka rk akilan
Greenhorn

Joined: Jan 04, 2013
Posts: 8
Hello am using spring 3.1.2

i got this error
java.lang.ClassCastException: org.springframework.web.servlet.mvc.ParameterizableViewController cannot be cast to org.springframework.web.method.HandlerMethod

===========================================================================================================================

@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
HttpSession currentSession = request.getSession();
HandlerMethod handlerMethod = (HandlerMethod) handler;
Class<? extends Object> entryClass = handlerMethod.getBean().getClass();

if (entryClass.isAnnotationPresent(Navigation.class)) {
@SuppressWarnings("unchecked")
List<NavigationEntry> prevPath = (List<NavigationEntry>) currentSession.getAttribute(NAVIGATION_PATH);
if (prevPath == null) {
prevPath = new ArrayList<NavigationEntry>();
}

List<NavigationEntry> basePath = buildBasePath(prevPath, entryClass);
NavigationEntry entry = generateNavigationEntry(entryClass, currentSession);
basePath.add(entry);
currentSession.setAttribute(NAVIGATION_PATH, basePath);
} else {
clearNavigationPath(currentSession);
}
}

====================================================================================================

i got this error in underlined line.

Please help me to sort out of this issue
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9319
    
  17

From what I can see from the documentation you get the controller instance in the handler object not an instance of HandlerMethod class. So instead of


You can directly do


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.lang.ClassCastException: ParameterizableViewController cannot be cast to HandlerMethod