Run a Job with Quartz and Spring

0

I need to run a job, I'm using quartz, but when the job runs I need to go to the database to make a query but it does not work, it returns the following error, I'm using Spring and Hibernate:

11:16:00.007 ERROR org.quartz.core.JobRunShell: Job MYJOB_GROUP.mailSenderJob threw an unhandled Exception: 
java.lang.NullPointerException
    at br.com.adminfo.xml.job.MailSenderJob.execute(MailSenderJob.java:45) ~[classes/:?]
    at org.quartz.core.JobRunShell.run(JobRunShell.java:213) [quartz-2.1.6.jar:?]
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:557) [quartz-2.1.6.jar:?]
11:16:00.007 ERROR org.quartz.core.ErrorLogger: Job (MYJOB_GROUP.mailSenderJob threw an exception.
org.quartz.SchedulerException: Job threw an unhandled exception.
    at org.quartz.core.JobRunShell.run(JobRunShell.java:224) [quartz-2.1.6.jar:?]
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:557) [quartz-2.1.6.jar:?]
Caused by: java.lang.NullPointerException
    at br.com.adminfo.xml.job.MailSenderJob.execute(MailSenderJob.java:45) ~[classes/:?]
    at org.quartz.core.JobRunShell.run(JobRunShell.java:213) ~[quartz-2.1.6.jar:?]
    ... 1 more

My Settings:

MailSenderJob.java:

@Override
public void execute(JobExecutionContext arg0) throws JobExecutionException {        
System.out.println("EXECUTION STARTING ...");
List<Empresa> listaEmpresas = empresas.findByEmailAutomatico(EmailAutomatico.ENVIAREMAIMENSALAUTOMATICAMENTE);
}

Quartz.properties:

org.quartz.scheduler.instanceName: MailScheduler
org.quartz.scheduler.instanceId: AUTO
org.quartz.scheduler.skipUpdateCheck: true
org.quartz.threadPool.class: org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount: 3
org.quartz.threadPool.threadPriority: 5
org.quartz.jobStore.misfireThreshold: 60000
org.quartz.jobStore.class: org.quartz.simpl.RAMJobStore
org.quartz.plugin.jobInitializer.class: org.quartz.plugins.xml.XMLSchedulingDataProcessorPlugin
org.quartz.plugin.jobInitializer.fileNames: mailsenderjobs.xml
org.quartz.plugin.jobInitializer.failOnFileNotFound: true
org.quartz.plugin.jobInitializer.scanInterval: 120
org.quartz.plugin.jobInitializer.wrapInUserTransaction: false

Web.xml:

<listener>
 <listener-class>
    org.quartz.ee.servlet.QuartzInitializerListener
 </listener-class>
</listener>
    
asked by anonymous 13.08.2018 / 16:27

0 answers