Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support standard javax.transaction.Transactional in AspectJ [SPR-11803] #16423

spring-issuemaster opened this issue May 17, 2014 · 3 comments


Copy link

@spring-issuemaster spring-issuemaster commented May 17, 2014

Marek Wiącek opened SPR-11803 and commented

AnnotationTransactionAspect currently only has pointcuts for org.springframework.transaction.annotation.Transactional annotations. Please add support for javax.ejb.TransactionAttribute and javax.transaction.Transactional.

Affects: 4.0.4

Issue Links:

  • #13778 Support for JTA 1.2 transaction annotation
  • #21525 AspectJ aspect for @javax.transaction.Transactional is not initialised by default

Referenced from: commits fa8d202

0 votes, 6 watchers


This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented May 30, 2014

Juergen Hoeller commented

The problem here is that both the JTA 1.2 Transactional annotation and the EJB 3 TransactionAttribute annotation aren't reliably on the runtime classpath of a Spring-based application. It's a challenge to bake them into AnnotationTransactionAspect's pointcut declarations without enforcing a hard dependency.

This would be less concerning if it's easy to add those extra dependencies to the classpath, but unfortunately both of those annotations can be in conflict with pre-defined JTA and EJB API jars in older EE environments.

The 'trick' that we're applying for proxy-based transaction interception is simply to use reflection with runtime presence checks... Maybe there's a way to do this with AspectJ as well; what's your take on it, Andy Clement?



This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Jun 5, 2014

Andy Clement commented

If we did add those other transaction types to a pointcut, we do have some tech (when LTW) to turn off aspects when certain types are not around:

<aspect name="Foo" requires=""/>

But that isn't very granular, it won't allow individual pointcuts to switch on and off depending on type availability. Which seems to be what we want here unless we want to construct multiple similar aspects?

You can do the reflective version using AspectJ that Juergen describes for proxies, but it'll be ugly:

before(): execution(* *(..)) {
  // do reflection on the method signature from thisJoinPointStaticPart to discover if annotation is around

Basically if we did add those types to the pointcuts in the transaction aspect, you are going to get typeNotFound messages at weave time (whenever that is). I have been thinking that typeNotFound is not necessarily the end of the world in all circumstances and maybe we need a way to indicate that to AspectJ. Right now you can dial down the message such that it is ignored but it is a separate step/flag that you need to tweak when consuming the library. What if we could:

pointcut p(): execution(* *(..)) && (within(@TransactionalA *) || within(@TransactionalB *));

If TransactionalA or TransactionalB is missing, this pointcut can still match if the other one is around. The suppression being expressed alongside the pointcut removes the problem of tweaking the message levels later (which is also a global switch, where this is a local switch). I've raised in AspectJ to cover doing something like this.


This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Feb 12, 2015

Stéphane Nicoll commented

We won't support javax.ejb.TransactionAttribute at this point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.