Announcement Announcement Module

Spring Modules forum decommissioned in favor of Spring Extensions

As the Spring Modules project has been replaced by the Spring Extensions ( project, this forum has been decommissioned in favour of Spring Extensions one at:

Please see the Spring Extensions home page for a complete list of current projects in Java, .NET and ActionScript. You can also propose one if you want.

Costin Leau
SpringSource - Spring Training, Consulting, and Support - "From the Source"
See more
See less
Validator nullpointerexception Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Validator nullpointerexception

    I am using this tutorial for enabling annotation based validation using spring bean validation framework. I am using spring modules 0.9 and spring 2.5.6

    I get NullPointerException when I hit the submit button


    java.lang.NullPointerException springmvc.web.CarNewController.onSubmit(CarNewCont sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method) sun.reflect.NativeMethodAccessorImpl.invoke(Native sun.reflect.DelegatingMethodAccessorImpl.invoke(De java.lang.reflect.Method.invoke( ndlerMethodInvoker.doInvokeMethod(HandlerMethodInv ndlerMethodInvoker.invokeHandlerMethod(HandlerMeth org.springframework.web.servlet.mvc.annotation.Ann otationMethodHandlerAdapter.invokeHandlerMethod(An org.springframework.web.servlet.mvc.annotation.Ann otationMethodHandlerAdapter.handle(AnnotationMetho org.springframework.web.servlet.DispatcherServlet. doDispatch( org.springframework.web.servlet.DispatcherServlet. doService( org.springframework.web.servlet.FrameworkServlet.p rocessRequest( org.springframework.web.servlet.FrameworkServlet.d oPost( javax.servlet.http.HttpServlet.service(HttpServlet .java:637) javax.servlet.http.HttpServlet.service(HttpServlet .java:717) --//

    This is how I use it in Controller


    // @Qualifier("beanValidator") private Validator validator;

    public void setValidator(Validator validator) {
    this.validator = validator;


    And this is the code in applicationcontext.xml
    class="org.springmodules.validation.bean.conf.load er.annotation.AnnotationBeanValidationConfiguratio nLoader"/>

    <bean id="validator" class="org.springmodules.validation.bean.BeanValid ator"

    <!-- Load messages -->
    <bean id="messageSource"
    class=" eBundleMessageSource"


    Applicationcontext.xml is loaded fine. I get the error when I hit submit.


    @RequestMapping(method=RequestMethod.POST) public ModelAndView onSubmit(@ModelAttribute("car")Car car,BindingResult bindingResult,HttpSession session) throws ServletException {

    if(bindingResult == null)"bindingResult is null");
    if(car == null)"Car is null");

    if(validator == null)"validator is null");
    validator.validate(car, bindingResult);


    "validator is null" is printed out..

    I am using Springmodules 0.9. Thanks for your quick help guys.