人人网框架地址:http://code.google.com/p/paoding-rose/
问题发生:
用Quartz作集群时用JobDataMap传递DAO,提示DAO未序列化,可框架的DAO为接口,在什么时候转为了对象的没看到。。。
以下是传递参数源码:
job = newJob(JobUserMail.class).withIdentity("job_usermail_" + reminders.getId(), "task_usermail").build();
job.getJobDataMap().put("orderIdDAO", orderIdDAO);
addjob(job, trigger);
接受参数源码:
@Override
public void execute(JobExecutionContext arg0) throws JobExecutionException {
JobDataMap data = arg0.getJobDetail().getJobDataMap();
OrderIdDAO orderIdDAO = (OrderIdDAO) data.get("orderIdDAO");
下面会引用这个 orderIdDAO
Reminders R = orderIdDAO.getById(remindersid);
OrderIdDAO源码:
@DAO
public interface OrderIdDAO extends Serializable{
@SQL("INSERT INTO orderid (orderid,orderdate)VALUES(NULL,:orderid.orderdate)")
public Identity create(@SQLParam("orderid") OrderId orderdate);
}
出错内容如下(部份):
org.quartz.JobPersistenceException: Couldn't store job: Unable to
serialize JobDataMap for insertion into database because the value of
property 'smsmobileDAO' is not serializable:
org.springframework.jdbc.core.JdbcTemplate [See nested exception:
java.io.NotSerializableException: Unable to serialize JobDataMap for
insertion into database because the value of property 'smsmobileDAO' is
not serializable: org.springframework.jdbc.core.JdbcTemplate]
at org.quartz.impl.jdbcjobstore.JobStoreSupport.storeJob(JobStoreSupport.java:1115)
at org.quartz.impl.jdbcjobstore.JobStoreSupport$2.executeVoid(JobStoreSupport.java:1062)
at org.quartz.impl.jdbcjobstore.JobStoreSupport$VoidTransactionCallback.execute(JobStoreSupport.java:3703)
at org.quartz.impl.jdbcjobstore.JobStoreSupport$VoidTransactionCallback.execute(JobStoreSupport.java:3701)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeInNonManagedTXLock(JobStoreSupport.java:3787)
at org.quartz.impl.jdbcjobstore.JobStoreTX.executeInLock(JobStoreTX.java:93)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.storeJobAndTrigger(JobStoreSupport.java:1058)
at org.quartz.core.QuartzScheduler.scheduleJob(QuartzScheduler.java:886)
at org.quartz.impl.StdScheduler.scheduleJob(StdScheduler.java:249)
at reyo.sdk.service.CronTriggerService.addjob(CronTriggerService.java:209)
at reyo.sdk.service.CronTriggerService.addMobileJob(CronTriggerService.java:184)
at reyo.sdk.service.CronTriggerService.init(CronTriggerService.java:68)
at reyo.sdk.service.CronTriggerService$$FastClassByCGLIB$$72d7b83d.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:713)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98)
at
org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:646)
at reyo.sdk.service.CronTriggerService$$EnhancerByCGLIB$$5d1ffd48.init(<generated>)
at reyo.sdk.quartz.InitTaskServlet.init(InitTaskServlet.java:27)
at javax.servlet.GenericServlet.init(GenericServlet.java:160)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1280)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1193)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1088)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5176)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5460)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1120)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1678)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)