I have a method in the controller:
public FormValidationResult submitFormAndSendEmail(@Valid ContactForm form, BindingResult result,
@HttpSessionParam(value = "lastTimeContactFormSent", required = false) Calendar lastTimeContactFormSent)
As you can see, I created the @HttpSessionParam annotation, this will take a variable from HttpSession and put it in the specified method parameter.
However...
Before resolving the argument, I get an instance of InstantiationExceptionConstructorAccessorImpl because the calendar cannot be created by the default constructor.
Using the given stack, I can see that HandlerMethodInvoker inside "resolveModelAttribute" causes an instance to be created.
How can I prevent this? I don't want to instantiate, I want to use my own WebArgumentResolver to populate the method parameter.
Any clues?
Additional Information: Stacktrace by Spring (3.0.4):
java.lang.InstantiationException
at sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:30)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:104)
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveModelAttribute(HandlerMethodInvoker.java:772)
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:356)
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:171)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:427)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:415)
, webargumentresolver.
(xml) :
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="customArgumentResolver" ref="sessionParamResolver"/>
</bean>
<bean id="sessionParamResolver" class="nl.usgpeople.vakgilde.spring.mvc.extensions.SessionParamArgumentResolver"/>