当我尝试在存储库中获取当前会话时,我收到以下异常。请建议解决此错误。我使用的是Spring 4.2.5,Quartz 2.2.1和hibernate 4.2.21
22:53:00,034 ERROR [org.quartz.core.JobRunShell]
(org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-1) Job DEFAULT.manualUploadFileProcessingJob抛出一个未处理的 例外:: org.springframework.scheduling.quartz.JobMethodInvocationFailedException: 在目标类[class]上调用方法'runTrigger' com.honeywell.zing.web.manualupload.utils.triggers.ManualUploadFileProcessingHandler] 失败;嵌套异常是org.hibernate.HibernateException: org.hibernate.HibernateException:无法获取 当前线程的事务同步会话 at org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean $ MethodInvokingJob.executeInternal(MethodInvokingJobDetailFactoryBean.java:266) [spring-context-support-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:75) [spring-context-support-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.quartz.core.JobRunShell.run(JobRunShell.java:202) [quartz-2.2.1.jar:] at org.quartz.simpl.SimpleThreadPool $ WorkerThread.run(SimpleThreadPool.java:573) [quartz-2.2.1.jar:]引起:org.hibernate.HibernateException: org.hibernate.HibernateException:无法获取 当前线程的事务同步会话
Quartz Scheduler
<bean id="manualUploadFileProcessingHandler" class="com.honeywell.zing.web.manualupload.utils.triggers.ManualUploadFileProcessingHandler">
<property name="soapUploadFileManager" ref="soapUploadFileManager"></property>
</bean>
<bean id="manualUploadFileProcessingJob" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="manualUploadFileProcessingHandler" />
<property name="targetMethod" value="runTrigger" />
<property name="concurrent" value="false" />
</bean>
<!-- Using job-store 'org.quartz.simpl.RAMJobStore' - which does not support persistence. and is not clustered.-->
<bean id="manualUploadFileProcessingTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<property name="jobDetail" ref="manualUploadFileProcessingJob" />
<property name="cronExpression" value="0 * * * * ?" /><!-- Every day Every hr Every min the trigger runs 0 * * * * ? -->
</bean>
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="jobDetails">
<list>
<ref bean="manualUploadFileProcessingJob" />
</list>
</property>
<property name="triggers">
<list>
<ref bean="manualUploadFileProcessingTrigger" />
<!-- <ref bean="expiryTrigger" /> <ref bean="WorkplansSyncTrigger"/>
<ref bean="RefreshConnectionPoolsTrigger" /> <ref bean="sampleExpiryTrigger"
/> <ref bean="unsentSampleDataToCAMPTrigger" /> <ref bean="unsentEmailLogsTrigger"
/> -->
</list>
</property>
</bean>
休眠:
@Repository
@Transactional
@EnableTransactionManagement
public class SoapUploadFileDaoImpl extends ZingHibernateDAO implements SoapUploadFileDao {
@Override
public List<RawFileRecord> getAllUnProcessedFiles() {
Session session = null;
try {
log.logInfo("ZING_MAN_INFO","getAllUnProcessedFiles","Fetching all unprocessed files for manual upload");
session = currentSession();
Query query = session.createQuery("from RawFileRecord rawFileRecord where rawFileRecord.processingStaus=:processingStatus");
query.setParameter("processingStatus", UNPROCESSED_PROCESSINGSTATUS);
return query.list();
} catch (HibernateException he) {
log.logError("ZING_MAN_INFO", "getAllUnProcessedFiles", "Error fetching unprocessed files ", he);
throw new HibernateException(he);
} catch(Exception ex){
log.logError("ZING_MAN_INFO", "getAllUnProcessedFiles", "Error fetching unprocessed files ", ex);
} finally {
//releaseSession(session);
}
return null;
}
}