• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

Spring commons-validator issue IlleagalArgumentException

 
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also pasting the code.

Controller



Command



application context xml



validation.xml

 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
murali kankanala
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But i am using spring 2.0 in my project, so i need a solution with common-validator only.
 
Bill Gorder
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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



 
reply
    Bookmark Topic Watch Topic
  • New Topic