0

I want to do some job in my event(CrudRepository(IgniteRepository)) repository. But when I have a constructor even the empty constructor I get an exception.

public class UpdateStatusJob implements Job {

    private TaskRepository TaskRepo;

    // UpdateStatusJob(){}


     UpdateStatusJob(TaskRepository taskRepo) throws
     JobExecutionException
     { 

       this.taskRepo= taskRepo; 

     }


    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {

        System.out.println("Events!!!!!");
    }


   }

Exception :

org.quartz.SchedulerException: Job instantiation failed at org.springframework.scheduling.quartz.AdaptableJobFactory.newJob(AdaptableJobFactory.java:45) at org.quartz.core.JobRunShell.initialize(JobRunShell.java:127) at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:392) Caused by: java.lang.InstantiationException: com.mphasis.eventinsights.scheduler.UpdateStatusJob at java.lang.Class.newInstance(Class.java:427) at org.springframework.scheduling.quartz.AdaptableJobFactory.createJobInstance(AdaptableJobFactor y.java:58) org.springframework.scheduling.quartz.AdaptableJobFactory.newJob(AdaptableJobFactory.java:41)

Caused by: java.lang.NoSuchMethodException: com.jp.tande.scheduler.UpdateStatusJob.() at java.lang.Class.getConstructor0(Class.java:3082) at java.lang.Class.newInstance(Class.java:412)

I need taskRepo to do some operations but failing call constructor.

Kramer
  • 389
  • 8
  • 34
  • Possible duplicate of [Not able inject bean in the component](https://stackoverflow.com/questions/33651601/not-able-inject-bean-in-the-component) (see also [this question](https://stackoverflow.com/questions/49858687/spring-cannot-inject-bean-in-class-that-implements-quartz-job)) – Morfic Mar 20 '19 at 14:06
  • @Morfic Getting null pointer exception if I am implementing according to above link – Kramer Mar 21 '19 at 08:16
  • And what did your investigation of the NPE reveal? – Morfic Mar 21 '19 at 10:52
  • @Morfic Thanks I solved it....was checking something silly....thanks your linked helped me to solve the problem – Kramer Mar 21 '19 at 12:26

0 Answers0