简体   繁体   English

Apache Tomcat 6 是否支持 JTA?

[英]Does Apache Tomcat 6 support JTA?

I have some confusion on using JTA within the Spring Framework on Apache Tomcat and i hope someone will clarify as after many research i can't seem to find the correct answer as of yet.我对在 Apache Tomcat 上的 Spring Framework 中使用 JTA 有一些困惑,我希望有人能澄清,因为经过多次研究,我似乎还没有找到正确的答案。

I am developing a web application using Spring Framework to be running on Apache Tomcat 6.我正在使用 Spring Framework 开发一个在 Apache Tomcat 6 上运行的 Web 应用程序。

I read somewhere that Spring's does support for JTA but it delegates to the underlying JavaEE application server.我在某处读到 Spring 确实支持 JTA,但它委托给底层 JavaEE 应用程序服务器。 Now this is where i am confused because i Tomcat is not a full JavaEE application server - it is merely a servlet container and as i believe it doesn't provide JTA implementation like the full JavaEE application server (Glassfish/Wildfly etc...) does.现在这是我感到困惑的地方,因为我的 Tomcat 不是一个完整的 JavaEE 应用程序服务器——它只是一个 servlet 容器,因为我相信它不提供像完整的 JavaEE 应用程序服务器(Glassfish/Wildfly 等...)做。

But when i do something like the following the transaction aspect of it works:但是,当我执行以下操作时,它的交易方面会起作用:

@Transactional
public class ServiceClassImpl implements ServiceInterface {
// code here that involves transactions e.g. calling DAO code
...
}

So, i'm confused.所以,我很困惑。 I hope someone will enlighten me.我希望有人能启发我。

The answer is: NO.答案是不。 Tomcat 6.x (7&8) don't provide JTA out-of-the-box because they don't have a transaction manager which is required as a separate component to monitor multiple resources (eg datasources). Tomcat 6.x (7&8) 不提供开箱即用的 JTA,因为它们没有需要作为单独组件来监视多个资源(例如数据源)的事务管理器。

The mentioned answer How to use JTA support in Tomcat 6 for Hibernate?提到的答案How to use JTA support in Tomcat 6 for Hibernate? already gives a list of additional JTA transaction managers that can be used alongside Tomcat.已经给出了可以与 Tomcat 一起使用的附加 JTA 事务管理器的列表。

Spring supports declarative transaction management via a platform transaction manager (TM) and provides some implementations (eg datasources) that make @Transactional work on a single resource without the additional TM. Spring 通过平台事务管理器 (TM) 支持声明式事务管理,并提供一些实现(例如数据源),使 @Transactional 在单个资源上工作,而无需额外的 TM。

Understanding the Spring Framework transaction abstraction provides more details and Spring Boot can be easily configured to run Atomikos or Bitronix Transaction managers on the embedded Tomcat. 了解 Spring Framework 事务抽象提供了更多详细信息,并且可以轻松配置Spring Boot以在嵌入式 Tomcat 上运行 Atomikos 或 Bitronix 事务管理器。

JTA 为您提供了分布式事务支持,但是如果 JTA 不像 Tomcat 那样可用,您仍然可以使用本地 JDBC 事务。

YES :-)是的 :-)

JTA can be used in Tomcat, for instance via https://www.atomikos.com JTA 可以在 Tomcat 中使用,例如通过https://www.atomikos.com

The trick is to use a componentized JTA implementation.诀窍是使用组件化的 JTA 实现。

Cheers干杯

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

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