Skip to content

Transactional attribute is not resolved on CgLib proxies created by FactoryBeans [SPR-7448] #12106

Closed

Description

@spring-projects-issues

Jan Novotný opened SPR-7448 and commented

When FactoryBean creates CgLib proxy via programmatic Spring proxy support (ie. ProxyFactory), @Transactional annotation on methods of original class are not picked by the transactional infrastructure. Reason is that the CgLib doesn't copies annotations on methods to the created final subclass and these annotations are not subject of inheritance.

See Jurgen Hoeller expression: https://jira.springframework.org/browse/SPR-975?page=com.atlassian.jira.plugin.system.issuetabpanels%253Aall-tabpanel

There is also open bug on CgLib - but I think it will never get resolved as the CgLib seems quite abadoned now: http://sourceforge.net/tracker/?func=detail&aid=2255414&group_id=56933&atid=482371

There is very simple solution that would address this issue (documented in attached file).

Issue is described in this blog post http://blog.novoj.net/2010/08/10/when-does-your-spring-transactional-attribute-apply-on-cglib-proxies/ in more detail.

Proposed solution is available at (see commentaries in referenced article): http://github.com/novoj/SpringTransactionTest


Affects: 2.5.6

Attachments:

Issue Links:

Referenced from: commits 99733ae

Activity

  1. spring-projects-issues commented on Aug 11, 2010

    @spring-projects-issues
    CollaboratorAuthor

    Juergen Hoeller commented

    This is a rather unusual scenario but you got a point there, so as of Spring 3.0.4, we introspect the superclass when given a CGLIB proxy as the target class. This has been implemented in the form of a ClassUtils.getUserClass call in AbstractFallbackTransactionAttributeSource.

    Juergen

  2. added
    type: bug
    in: data
    on Jan 11, 2019
  3. added this to the 3.0.4 milestone on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: datatype: bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions