Java HIbernate 4 Spring 4.2.2:“;无法获取当前线程的事务同步会话";在注入财产时

Java HIbernate 4 Spring 4.2.2:“;无法获取当前线程的事务同步会话";在注入财产时,java,xml,spring,hibernate,Java,Xml,Spring,Hibernate,我有一个相当复杂的情况,并尝试了我能找到的一切资源;我已经问过这个问题,但是我有很多新的信息,所以我将再次发布这个问题(现在重新措辞) 所以,我有一个 extract-ws-context.xml 其中包括: <import resource="classpath:weblogic-env-context.xml"/> <import resource="classpath:dao-context.xml"/> <import resource="classpath

我有一个相当复杂的情况,并尝试了我能找到的一切资源;我已经问过这个问题,但是我有很多新的信息,所以我将再次发布这个问题(现在重新措辞)

所以,我有一个 extract-ws-context.xml

其中包括:

<import resource="classpath:weblogic-env-context.xml"/>
<import resource="classpath:dao-context.xml"/>
<import resource="classpath:business-context.xml"/>
<import resource="classpath:extract-ws-context.xml"/>
<import resource="classpath*:/jobs/extract-unmarsh-context.xml"/>
<import resource="classpath*:/jobs/batch-context.xml"/>
<import resource="classpath*:/jobs/extract-job.xml"/>
<import resource="classpath*:/ws-context.xml"/>
奇怪的是:

对于某些对getSession()的调用,会返回一个会话;对于我当前正在处理的调用,getSession()会抛出一个“org.hibernate.hibernateeException:无法获取当前线程的事务同步会话”

(具有以下堆栈跟踪:)

在extract-ws.xml中定义:

<context:component-scan base-package="be.fgov.just.cjr.ws.extract"/>

<tx:annotation-driven transaction-manager="transactionManager"/>
ExtractWSService的定义如下:

package be.fgov.just.cjr.ws.extract.service;

//imports

@Slf4j
@Getter
@Setter
@Transactional
@Service
public class ExtractWSServiceImpl implements ExtractWSService {
extract-ws.xml在“extract-ws-context.xml”中导入(如上图所示,在extract-ws-context.xml中导入)

创建此bean时,将执行以下代码:

public void setLovDao(ListOfValuesDao lovDao) {
    toSend = lovDao.getNotificationStatus(TO_SEND);
    error = lovDao.getNotificationStatus(ERROR);
    erased = lovDao.getNotificationStatus(ERASED);
    sent = lovDao.getNotificationStatus(SENT);
    on_hold = lovDao.getNotificationStatus(ON_HOLD);
}

    toSend = lovDao.getNotificationStatus(TO_SEND);
打电话的结果是打电话给

getSession()
显示在这篇文章的顶部

我想我的问题可以归结为:

1) 当Spring创建bean/自动连接/注入时,如何获得会话 性质

2) 如果这已经不可能了,为什么以前可能,以及:

3) 如何从hibernate获取数据来初始化bean

感谢阅读/指点/帮助


这只是一种感觉。。。在stacktrace中,我看到错误与侦听器有关;类
NotificationPredicateEvaluator
的init方法(构造函数?)中似乎有一个NPE;你查过这门课了吗?一切正常吗?您的
notificationService
bean似乎在其
init()
方法上抛出了一个NPE。请尝试spring boot。看到这个答案:嘿,谢谢@emoleumasi的提示,我明天会试试(不能从家里联系办公室网络)
2015-Nov-09 16:37:50.634 ERROR [http.MessageDispatcherServlet] : Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'extractWSServiceEndpoint': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private be.fgov.just.cjr.ws.extract.service.ExtractWSService be.fgov.just.cjr.ws.extract.service.ExtractWSServiceEndpoint.extractWSService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'extractWSServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private be.fgov.just.cjr.business.dossier.DossierService be.fgov.just.cjr.ws.extract.service.ExtractWSServiceImpl.dossierService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'DossierService' defined in class path resource [business-context.xml]: Cannot resolve reference to bean 'NotificationChangeEventBus' while setting bean property 'eventBus'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'NotificationChangeEventBus' defined in class path resource [business-context.xml]: Cannot resolve reference to bean 'NotificationChangeListener' while setting bean property 'listener'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'NotificationChangeListener' defined in class path resource [business-context.xml]: Cannot resolve reference to bean 'NotificationRuleEngine' while setting bean property 'notificationRuleEngine'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'NotificationRuleEngine' defined in class path resource [business-context.xml]: Cannot resolve reference to bean 'NotificationPredicateEvaluator' while setting bean property 'notificationPredicateEvaluator'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'NotificationPredicateEvaluator' defined in class path resource [business-context.xml]: Cannot resolve reference to bean 'NotificationService' while setting bean property 'notificationService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'NotificationService': Invocation of init method failed; nested exception is java.lang.NullPointerException
<context:component-scan base-package="be.fgov.just.cjr.ws.extract"/>

<tx:annotation-driven transaction-manager="transactionManager"/>
package be.fgov.just.cjr.ws.extract.service;

//imports

@Endpoint
public class ExtractWSServiceEndpoint {

    @Autowired
    private ExtractWSService extractWSService;      
package be.fgov.just.cjr.ws.extract.service;

//imports

@Slf4j
@Getter
@Setter
@Transactional
@Service
public class ExtractWSServiceImpl implements ExtractWSService {
public void setLovDao(ListOfValuesDao lovDao) {
    toSend = lovDao.getNotificationStatus(TO_SEND);
    error = lovDao.getNotificationStatus(ERROR);
    erased = lovDao.getNotificationStatus(ERASED);
    sent = lovDao.getNotificationStatus(SENT);
    on_hold = lovDao.getNotificationStatus(ON_HOLD);
}
    toSend = lovDao.getNotificationStatus(TO_SEND);
getSession()