繁体   English   中英

Struts 2 execAndWait + Spring 事务管理集成

[英]Struts 2 execAndWait + Spring transaction management integration

我正在执行一个需要一段时间的操作,所以我使用了自定义 Struts 的ExecuteAndWaitInterceptor 我启动了一个自定义的BackgroundProcess ,它在调用之前打开一个事务,并在调用之后关闭它。

我正在调用的操作使用具有以下 Spring 事务建议的服务:

<tx:method name="search" propagation="REQUIRED" />

但是,当我执行此操作时,出现以下错误:

Could not open Hibernate Session for transaction; nested exception 
  is org.hibernate.TransactionException: nested transactions not supported

我猜这是因为 Spring 无法看到在BackgroundProcess中打开的事务并尝试打开一个新的事务。 因此,发生此错误。

如何配置我的BackgroundProcess以便它打开 Spring 看到的事务?

或者如何阻止 Spring 在运行BackgroundProcess时进行干扰?

应该为 spring bean 配置 Spring 管理的事务。 您无法管理在没有上下文的情况下创建的 bean 上的事务。

因此,您要么必须配置 Spring 以使用 bean 的托管实例,要么将其从事务建议中排除。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM