troubleshooting Question

spring, quartz, jpa, hibernate

Avatar of faihandhope
faihandhope asked on
Java EEJava
16 Comments1 Solution2246 ViewsLast Modified:
Hello experts, I hope you can help me.

I am using quartz to run jobs in a web application.  Works fine if the job is to just print "say hello", and will trigger every 5 seconds.

But when I modified the job, and added a call to the EntityManager service to get the data. It does not run at all.

Below is the code.  Also the applicatonContext.xml file where spring is referencing the job.

Any help, is appreciated.
My job is called
public class TestQuartz extends QuartzJobBean   {
	   private Collection<EmailEntity> emails;
	   private EmailEntity email;
                   	   private EmailService es;
	    public void setEs(EmailService es) { = es;
    protected void executeInternal(JobExecutionContext ctx)  throws JobExecutionException {
	//this does not work at all
   	emails = es.findAll(); 
   	if (emails.size() > 0) {
   		System.out.println("got data");
	 System.out.println("Hello from Spring and Quartz");
applicatonContext.xml :
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""
    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="dataSource" ref="dataSourceSQL"/>
        <property name="jpaVendorAdapter">
            <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                <property name="showSql" value="false"/>
                <property name="generateDdl" value="true"/>
    <bean id="dataSourceSQL"
        <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
        <property name="url" value="jdbc:hsqldb:hsql://localhost/xdb"/>
        <property name="username" value="sa"/>
    <bean id="transactionManager"
        <property name="entityManagerFactory" ref="entityManagerFactory"/>
<bean name="exampleJob" class="org.springframework.scheduling.quartz.JobDetailBean">
  <property name="jobClass" value="TestQuartz"/>
  <property name="jobDataAsMap">
      <entry key="timeout" value="5"/>
      <entry key="es" value="com.vaannila.service.admin.EmailService"/>
    <tx:annotation-driven transaction-manager="transactionManager"/>
    <context:component-scan base-package="com.vaannila"/>

Open in new window


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 16 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 16 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros