Announcement Announcement Module
Collapse
No announcement yet.
getting error after converting XML based configuration to java annotation based Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • getting error after converting XML based configuration to java annotation based

    Hi ALL ,

    I'm getting below error while converting XML based configuration to java annotation based .

    Code:
    SEVERE: Servlet.service() for servlet [dispatcher] in context with path [/CST] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause
    java.lang.NullPointerException
    	at org.springframework.validation.beanvalidation.SpringValidatorAdapter.validate(SpringValidatorAdapter.java:102)
    	at org.springframework.validation.DataBinder.validate(DataBinder.java:729)
    	at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.doBind(HandlerMethodInvoker.java:815)
    	at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:367)
    	at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:171)
    	at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436)
    	at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424)
    	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
    	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
    	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:917)
    	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:824)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
    	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:798)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
    	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
    	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    	at java.lang.Thread.run(Unknown Source)

    below is my XML and equivalent java annotation based configuration , XML based configuration was working fine .

    Code:
    <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
    <property name="webBindingInitializer">
    <bean class="org.springframework.web.bind.support.ConfigurableWebBindingInitializer">
    <property name="validator" ref="validator" />
    </bean>
    </property>
    </bean>
    
    <!-- Creates the JSR-303 Validator -->
    <bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" />
    Code:
    @Bean 
    public AnnotationMethodHandlerAdapter annotationHandler(){
    AnnotationMethodHandlerAdapter amha= new AnnotationMethodHandlerAdapter();
    ConfigurableWebBindingInitializer cwbi = new ConfigurableWebBindingInitializer();
    cwbi.setValidator(new LocalValidatorFactoryBean());
    amha.setWebBindingInitializer(cwbi);
    return amha;
    }

  • #2
    getting error after converting XML based configuration to java annotation based

    Hi , Please help me on below issue . just Fyi , if i will commented out java configuration code and will use xml configuration , the code will work fine .

    Originally posted by Raju_Rathi View Post
    Hi ALL ,

    I'm getting below error while converting XML based configuration to java annotation based .

    Code:
    SEVERE: Servlet.service() for servlet [dispatcher] in context with path [/CST] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause
    java.lang.NullPointerException
    	at org.springframework.validation.beanvalidation.SpringValidatorAdapter.validate(SpringValidatorAdapter.java:102)
    	at org.springframework.validation.DataBinder.validate(DataBinder.java:729)
    	at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.doBind(HandlerMethodInvoker.java:815)
    	at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:367)
    	at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:171)
    	at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436)
    	at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424)
    	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
    	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
    	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:917)
    	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:824)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
    	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:798)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
    	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
    	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    	at java.lang.Thread.run(Unknown Source)

    below is my XML and equivalent java annotation based configuration , XML based configuration was working fine .

    Code:
    <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
    <property name="webBindingInitializer">
    <bean class="org.springframework.web.bind.support.ConfigurableWebBindingInitializer">
    <property name="validator" ref="validator" />
    </bean>
    </property>
    </bean>
    
    <!-- Creates the JSR-303 Validator -->
    <bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" />
    Code:
    @Bean 
    public AnnotationMethodHandlerAdapter annotationHandler(){
    AnnotationMethodHandlerAdapter amha= new AnnotationMethodHandlerAdapter();
    ConfigurableWebBindingInitializer cwbi = new ConfigurableWebBindingInitializer();
    cwbi.setValidator(new LocalValidatorFactoryBean());
    amha.setWebBindingInitializer(cwbi);
    return amha;
    }

    Comment

    Working...
    X