GeeCON Prague 2014*
The moose likes Spring and the fly likes Spring commons-validator issue IlleagalArgumentException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring commons-validator issue IlleagalArgumentException" Watch "Spring commons-validator issue IlleagalArgumentException" New topic
Author

Spring commons-validator issue IlleagalArgumentException

murali kankanala
Ranch Hand

Joined: Nov 15, 2004
Posts: 110
Hi I am trying to use commons-validator framework for validation in Spring MVC. i am getting following exception.

java.lang.IllegalArgumentException: Validator [org.springmodules.commons.validator.DefaultBeanValidator@1d5b945] does not support command class [com.training.springmvc.Details]


I have attached code in zip file. Could you please help me to resolve the issue.
murali kankanala
Ranch Hand

Joined: Nov 15, 2004
Posts: 110
Also pasting the code.

Controller



Command



application context xml



validation.xml

Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1650
    
    7

I would start with using the annotation based controllers which is the accepted way do controllers since Spring 2.5. There should not be a need to extend SimpleFormController. If you are using newer versions of Spring they have full support for the JSR303 Bean validation API. You can use these and just add hibernate-validator to your classpath.

See the reference documentation
http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/validation.html#validation-beanvalidation


[How To Ask Questions][Read before you PM me]
murali kankanala
Ranch Hand

Joined: Nov 15, 2004
Posts: 110
But i am using spring 2.0 in my project, so i need a solution with common-validator only.
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1650
    
    7

The name of your command class must match the "name" attribute in yourform definition in validation.xml. If this is unacceptable you can look at using ConfigurableBeanValidator instead of DefaultBeanValidator.

http://www.springbyexample.org/maven/site/org.springbyexample.validation/0.94/apidocs/org/springmodules/validation/commons/ConfigurableBeanValidator.html

murali kankanala
Ranch Hand

Joined: Nov 15, 2004
Posts: 110
You are right , i was assuming , in the below code i have set "user" as form name what being used in jsp to read from request scope. Usually in struts we assume this is the name that we have to use in validation.xml. Hmm but in spring it is different.



Now what i understand is below



 
GeeCON Prague 2014
 
subject: Spring commons-validator issue IlleagalArgumentException