I'm tring to understand ejb3 and JTA relation. Can JEE application server implement JTA without implement EJB3 ? If my code run on JBoss 7 , so isn't it enough to use JTA and JPA (without ejb annotation) annotation to handle transactions ?
1 Answers
Yes, an application server can implement JTA without EJB. Yes, if all you need from your application server is transactions, then the container-managed transaction support in EJBs is probably not a compelling enough reason to use the EJB programming model, particularly if you have access to an application server that supports the @Transactional
annotation.
The EJB programming model is a combination of a variety of disparate technologies, and over time the various capabilities are either being split out so they can be used without the entirety of the EJB programming model (e.g., @Transactional
for container-managed transactions, or JSR 236 for some uses of EJB timers) or are being phased out (e.g., entity beans replaced by JPA, or remote EJB being less important with the industry moving towards REST). As an application developer, you have to try to hit a sweet spot between using programming models that make you more productive without using so many programming models that your application only runs on large/monolithic application servers with large overheads. If you need EJB for other reasons, then it probably makes sense to use its container-managed transactions, but if you don't, then it probably doesn't.