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

TransactionSynchronizationUtils.unwrapResourceIfNecessary() does not unwrap OSGi service proxies [SPR-7368] #12026

Closed
spring-projects-issues opened this issue Jul 13, 2010 · 5 comments
Assignees
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

Ric Klaren opened SPR-7368 and commented

We experienced deadlocks in our product while load testing. The issue occurs when mixing Hibernate Sessions with JdbcTemplate code. What basically happens:

  1. The session in view filter creates a new Hibernate Session.
  2. The HibernateTransactionManager registers a JDBC datasource in the thread local map using the real class.
  3. Somewhere in a service call (and transaction) the user details are requested via the JdbcUserDetailsManager (from spring security) which is implemented as a JdbcTemplate. The JdbcTemplate has a JDK proxy of the datasource. This leads to a lookup in the thread local map with the proxy in stead of the real data source. Since TransactionSynchronizationUtils.unwrapResourceIfNecessary() does not unwrap JDK proxies the lookup fails. As a result the existing connection is not reused and a new connection is requested from the connection pool.

This deadlocks when the connection pool has no connections left.

(Checked the code up to 3.0.3 Release in which this is also present)


Affects: 3.0 GA

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

What kind of DataSource proxy is it that your JdbcTemplate is talking to? Are you applying aspects to it by any chance?

Juergen

@spring-projects-issues
Copy link
Collaborator Author

Ric Klaren commented

It is a Spring DM imported bean from another OSGi bundle (and as such a proxy). Now I start to wonder if it can be unwrapped at all....

@spring-projects-issues
Copy link
Collaborator Author

Ric Klaren commented

It looks like its fixed by upgrading the spring framework in Spring DM Server to spring 3.0.3.

Cheers,

Ric

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Alright - good to hear that it works for you against 3.0.3!

This should be fixed since 3.0.1, actually, so I'm marking this as resolved for 3.0.1 now.

Juergen

@spring-projects-issues
Copy link
Collaborator Author

Ric Klaren commented

I'm afraid I was not able to test with 3.0.1 I ran into issues with spring security and the various 3.0.1 bundles (RELEASE/RELEASE-A).

Thank you for looking into it.

Cheers,

Ric

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants