Search code examples
xmljava-8spring-batchquartz

Caused by: java.lang.NoSuchMethodException Spring Batch xml configuration


I have a batch process which executes weekly on Fridays. Spring xml configuration is as follows.

   <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    <property name="triggerpo">
          
        <ref bean="cronTriggerForProcessOrder"/>
        
      
      </property>
  </bean>

    
    <bean id="cronTriggerForProcessOrder" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
        <property name="jobDetail" ref="jobForProcessOrders" />
        <property name="cronExpression" value="0 0 0 ? * FRI" />
    </bean>

    <bean id="jobForProcessOrders"
        class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
        <property name="targetObject" ref="ProcessOrdersController" />
        <property name="targetMethod" value="processOrders"/>
        <property name="concurrent" value="false" />
    </bean>
 <bean id="ProcessOrdersController" class="com.java.app.web.controller.ProcessOrderController">
        
    </bean>

In the controller removed @controller annotation as it says the controller initialized multiple times. Now I am getting an error while tomcat startup .

Caused by: java.lang.NoSuchMethodException: com.java.app.web.controller.ProcessOrderController.processOrders()

The method processOrders do exists in the controller.

    @RequestMapping(value="/processorder")
public class ProcessOrderController {

@RequestMapping(value="/processOrders.do")
    public ModelAndView processOrders(HttpServletRequest req, HttpServletResponse res) throws AppException{
        ModelAndView mav = new ModelAndView();
        mav.setViewName("processorder");
        processOrders();
        return mav;
    }
    }

I am not sure what mistake I made in this. Could any one please help me to understand ? I can provide more info on request.

Also would like to know how I can eliminate xml configuration and use pure annotation based code.


Solution

  • I believe it's trying to find a method without parameters, but yours HttpServletRequest req, HttpServletResponse res.

    As a test, I suggest you to try to remove those parameters. If you don't get that error, you know at least in which direction to look ;)