Another exception happened to me today while im deploying my application to Tomcat 7, somehow the error (again) never happen on my IDE. The error is related to Spring MVC’s @PathVariable. Below is the complete stacktrace for the error.
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalArgumentException: Name for argument type [java.lang.String] not available, and parameter name information not found in class file either. org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:894) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778) javax.servlet.http.HttpServlet.service(HttpServlet.java:621) javax.servlet.http.HttpServlet.service(HttpServlet.java:722) com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:119) com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:55) org.springframework.security.web.FilterChainProxy$VirtualFilterChain .doFilter(FilterChainProxy.java:330) org.springframework.security.web.access.intercept.FilterSecurityInterceptor .invoke(FilterSecurityInterceptor.java:118) org.springframework.security.web.access.intercept.FilterSecurityInterceptor .doFilter(FilterSecurityInterceptor.java:84)
And this is the suspected method which raise exception,
@RequestMapping(value ="/baculsoft/news/view/{id}", method = RequestMethod.GET)
public String newsView(ModelMap modelMap,
@PathVariable String id) {
modelMap.put("news", newsService.get(id);
return "news/view";
}
The workaround is actually simple, below is how to deal with it,
@RequestMapping(value ="/baculsoft/news/view/{id}", method = RequestMethod.GET)
public String newsView(ModelMap modelMap,
@PathVariable("id") String id) {
modelMap.put("news", newsService.get(id);
return "news/view";
}
Actually very simple workaround, but since i have hundreds of methods using @PathVariable, it’s not so simple anymore. And the weird thing is, the .war exported from Eclipse IDE run perfectly, only .war created from Netbeans that raise exception. I dont know why, but somehow Netbeans’ ant create a different war compared to Eclipse’s war file.
After sometimes googling, i found out that it happens due to javac’s debug parameter on Netbeans’ ant, changing “debug” default value into “on” on Netbeans’ build-impl.xml makes my war file run perfectly on Tomcat 7. Well i hope it hepled others, cheers (B)