Skip to content

Optional @RequestParam with required=false no longer works in Spring 3.0.4 (compared to 3.0.2) when Controller extends interface [SPR-7483] #12141

@spring-projects-issues

Description

@spring-projects-issues

Grant Gochnauer opened SPR-7483 and commented

In order to work around CGLIB and AOP memory issues all of our MVC controllers extend Interfaces for proxying.

We have something like this in our interface:

@RequestMapping(value = "/contactus.htm", method = RequestMethod.POST)
 ModelAndView handleContactUsSubmit(HttpServletRequest request, HttpServletResponse response,
                                    @RequestParam(value = "pUrl", required = false) String promotionUrl, @ModelAttribute ContactUsModel model,
                                    Errors errors);

And in the class:

@ExposeSharedPageAttributes
    public ModelAndView handleContactUsSubmit( HttpServletRequest request, HttpServletResponse response, @RequestParam(value = "pUrl", required = false) String promotionUrl, @ModelAttribute ContactUsModel model,
            Errors errors )
    {

This worked great in Spring 3.0.2. After upgrading to 3.0.4, I receive the following stack trace:

Caused by: org.springframework.web.bind.annotation.support.HandlerMethodInvocationException: Failed to invoke handler method [public final org.springframework.web.servlet.ModelAndView $Proxy100.handleContactUsSubmit(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,java.lang.String,com.roche.cwp.web.template.contactus.model.ContactUsModel,org.springframework.validation.Errors)]; nested exception is java.lang.IllegalStateException: No parameter name specified for argument of type [java.lang.String], and no parameter name information found in class file either.
	at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:181)
	at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:427)
	at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:415)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:788)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:717)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
	... 81 more
Caused by: java.lang.IllegalStateException: No parameter name specified for argument of type [java.lang.String], and no parameter name information found in class file either.
	at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.getRequiredParameterName(HandlerMethodInvoker.java:731)
	at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveRequestParam(HandlerMethodInvoker.java:480)
	at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:340)
	at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:171)
	... 86 more



Affects: 3.0.4

Referenced from: commits 284f98f

1 votes, 5 watchers

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions