Announcement Announcement Module
Collapse

Spring Modules forum decommissioned in favor of Spring Extensions

As the Spring Modules project has been replaced by the Spring Extensions (http://www.springsource.org/extensions) project, this forum has been decommissioned in favour of Spring Extensions one at:
http://forum.springsource.org/forumdisplay.php?f=44

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.

Cheers,
Costin Leau
SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
http://twitter.com/costinl
See more
See less
Validator nullpointerexception Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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

    http://wheelersoftware.com/articles/...=true#comments

    I get NullPointerException when I hit the submit button

    //--

    java.lang.NullPointerException springmvc.web.CarNewController.onSubmit(CarNewCont roller.java:139) sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method) sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39) sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25) java.lang.reflect.Method.invoke(Method.java:597) org.springframework.web.bind.annotation.support.Ha ndlerMethodInvoker.doInvokeMethod(HandlerMethodInv oker.java:421) org.springframework.web.bind.annotation.support.Ha ndlerMethodInvoker.invokeHandlerMethod(HandlerMeth odInvoker.java:136) org.springframework.web.servlet.mvc.annotation.Ann otationMethodHandlerAdapter.invokeHandlerMethod(An notationMethodHandlerAdapter.java:326) org.springframework.web.servlet.mvc.annotation.Ann otationMethodHandlerAdapter.handle(AnnotationMetho dHandlerAdapter.java:313) org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:875) org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:807) org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:571) org.springframework.web.servlet.FrameworkServlet.d oPost(FrameworkServlet.java:511) javax.servlet.http.HttpServlet.service(HttpServlet .java:637) javax.servlet.http.HttpServlet.service(HttpServlet .java:717) --//

    This is how I use it in Controller

    //--

    @Autowired(required=true)
    // @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"
    p:configurationLoader-ref="configurationLoader"/>


    <!-- Load messages -->
    <bean id="messageSource"
    class="org.springframework.context.support.Resourc eBundleMessageSource"
    p:basenames="errors"/>

    --//

    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)
    logger.info("bindingResult is null");
    if(car == null)
    logger.info("Car is null");

    if(validator == null)
    logger.info("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.
Working...
X