New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSR-303 @Valid validation is not invoked for @RequestBody controller method arguments [SPR-6709] #11375
Comments
Michal Huniewicz commented Yep, I confirm this. I have the same problem. |
Arjen Poutsma commented Rossen, could you take a look at this one? |
Vijay Dendukuri commented I'm using 3.1 M2, But i'm still getting the following exception. java.lang.IllegalStateException: Errors/BindingResult argument declared without preceding model attribute. Check your handler method signature! |
Vijay Dendukuri commented I take it back, Actually its working now. With out the BindingResult Argument |
Alexander Shabanov commented The issue still reproduced on 3.1.0.RELEASE |
Rossen Stoyanchev commented Is it possible that you're using the AnnotationMethodHandlerAdapter still? New features in annotated controllers require switching to the support classes listed here. |
Alexander Shabanov commented Yes, I think this is the reason. I didn't try it yet, but I'm pretty sure this would solve the problem. Please, close the bug. |
Rossen Stoyanchev commented Resolving as requested. |
Mike Finney commented I also got a java.lang.IllegalStateException: Errors/BindingResult argument declared without preceding model attribute. Check your handler method signature! I am using Spring 3.1.0.RELEASE. Other than using the 3.1.0 jars, how can I make sure I am using the latest "support classes" listed here: http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/new-in-3.1.html#d0e1515 Is there a xml declaration or java config I should do? |
Rossen Stoyanchev commented See comment by Vijay above. You need to remove the BindingResult or Errors method argument. That can only be used after a |
chris fang commented
|
Rossen Stoyanchev commented The idea here is that |
Scott Frederick commented
|
chris fang commented
Thanks a lot. |
Rossen Stoyanchev commented I think Scott meant MethodArgumentNotValidException. This is described in the documentation and in the javadoc of |
Scott Frederick commented Actually, I was guessing at the exception that would be thrown, based on what Spring 3.0 throws when DataBinder gets a validation error. I guess I should check my assumptions before I give answers (or at least say that I'm guessing). </blush> Thanks for the correction Rossen. |
Thomas Bruyelle commented There is blog post that suggests a solution for this issue by using the |
Rossen Stoyanchev commented The blog post was written before this issue was resolved. |
rajeev singla commented I am still getting the error I am using <spring.version>3.1.0.RELEASE</spring.version> and if I do java.lang.IllegalStateException: An Errors/BindingResult argument is expected to be immediately after the model attribute argument in the controller method signature: public java.lang.String insertOrg(Org,java.lang.String,java.lang.String,java.lang.String,org.springframework.validation.BindingResult) |
Scott Frederick commented Rajeev, The problem you are having is not related to using If that doesn't fix your problem, I suggest you post to the Spring Forum (http://forum.springsource.org/forumdisplay.php?25-Web) with the code for the controller. |
Thomas Bruyelle commented Rajeev, I use Like Scott said, your problem is about the Exception @ExceptionHandler
public void handleMethodArgumentNotValidException( MethodArgumentNotValidException error )
{
(...) error.getBindingResult() (...)
} |
rajeev singla commented Thanks for response Scott and Thomas. |
Puneet Pandey commented Scott and Thomas: I use this combination of The issue I get while deploying my code is : Failed startup of context o.m.j.p.JettyWebAppContext{/,file:/D:/SAMS-2013/WORKSPACE-06/com.sams.validation/src/main/webapp/},file:/D:/SAMS-2013/WORKSPACE-06/com.sams.validation/src/main/webapp/ Is it that the combination of |
Puneet Pandey commented Is it that the combination of |
Scott Frederick commented I don't see anything to indicate that the combination of |
Puneet Pandey commented Scott: I too couldn't see any relation between Validation annotations and ZipException. Unfortunately, however, I was getting the exception only when I was changing the Spring version. I could process a little further but couldn't get the issue resolved completely. Will post the issue in Springsource forum too. Thanks! |
Puneet Pandey commented Hi Scott: Posted the issue to the SpringSource: http://forum.springsource.org/showthread.php?135923-Spring3-MVC-annotation-driven-Rest-Services-in-OSGi-environment-bean-validation-issue&p=441701#post441701 |
Oliver Drotbohm commented An exception like this usually indicates corrupted JAR files. Have you tried purging your local Maven repo (or equaivalent) and re-grabbing the binaries? |
Puneet Pandey commented Oliver: You are correct, it was actually a case of corrupted jar. I have actually progressed and deployed the code to the Virgo Server. But, still could not get it to work. Have posted the issue to the SpringSource. Please have a look into it and suggest. Link: |
Scott Frederick opened SPR-6709 and commented
If an argument to a Spring MVC Controller method is annotated with both the
@RequestBody
and@Valid
annotations, the argument should be passed to the validation framework after being populated, but the validation is not invoked.More details and an example are included in the forum thread.
Affects: 3.0 GA
Reference URL: http://forum.springsource.org/showthread.php?t=81563
Referenced from: commits f1ad53d, 9d2ee70, 18f5d90
26 votes, 30 watchers
The text was updated successfully, but these errors were encountered: