Perform a Job with Quartz and Spring

Asked

Viewed 110 times

0

I need to run a job, I am using Quartz, but when the job is executed I need to go to the database to make a query but it does not work, returns the following error, I am 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>
  • 2

    More information is needed so that we can help. Apparently, the problem is configuration, but it is difficult to know which one! For you to understand, we have no way of knowing where line 45 is pointed by NPE tracing.

  • 2

    @Zulian Read this: https://pt.meta.stackoverflow.com/q/5359/132

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.