|
From: <jue...@we...> - 2004-12-28 13:31:30
|
Hi Calvin,
=20
It is indeed supposed to be impossible for those unbindResource calls to =
fail. Spring's transaction synchronization code (or OpenSessionInView =
code) should be the only place where binding and unbinding of =
thread-specific resources happens.
=20
The only exception is JTA synchronization in a remote transaction =
scenario: If the transaction coordinator resides in a different process, =
the synchronization callbacks will not happen in the same thread that =
performed the original data access. This is why Spring performs a =
hasResource check in the JTA transaction section of =
SpringSessionSynchronization's beforeCompletion (since release 1.1.3).
=20
So why is the SessionHolder already removed from the current thread when =
that code is reached in your scenario? You're obviously about to =
complete a JTA transaction - I assume with no remote transactions =
involved -, so who removed that SessionHolder from the thread during =
that transaction?
=20
Juergen
=20
________________________________
Von: spr...@li... im Auftrag =
von Calvin Smith
Gesendet: Di 28.12.2004 00:15
An: spr...@li...
Betreff: [Springframework-developer] =
TransactionSynchronization.beforeCompletion and =
TransactionSynchronizationManager.unbindResource problems
I'm having a problem with
TransactionSynchronizationManager.unbindResource trying to unbind a
resource that has already been unbound (and throwing
IllegalStateException). This was occuring for me in the beforeCompletion
methods of
org.springframework.orm.hibernate.SessionFactoryUtils$SpringSessionSynchr=
onization
(line 788) and
org.springframework.jdbc.datasource.DataSourceUtils$ConnectionSynchroniza=
tion
(344).
I tried changing SpringSessionSynchronization (788) from
TransactionSynchronizationManager.unbindResource(this.sessionFactory);
to
if (TransactionSynchronizationManager.hasResource(this.sessionFactory)) =
{
=
TransactionSynchronizationManager.unbindResource(this.sessionFactory);
}
and ConnectionSynchronization (344) from
TransactionSynchronizationManager.unbindResource(this.dataSource);
to
if (TransactionSynchronizationManager.hasResource(this.dataSource)) {
TransactionSynchronizationManager.unbindResource(this.dataSource);
}
and my problem disappeared. I'm not sure if it's supposed to be
impossible for those unbindResource calls to fail (only Spring-code
calls them, and I do everything through JtaTransactionManager
(declaratively at times and with TransactionTemplate at other times)),
or if it is failing for some other reason, but I'm hoping the person who
wrote/owns that code might have some insight.
The context in which this is occurring is a pretty complex
Spring-managed Jta/Jotm transaction in which both Hibernate and straight
Jdbc operations are occuring (including operations that originate from
OSWorkflow, Quartz, and application code via JdbcTemplate).
It looks like the other implementations of this method
(org.springframework.orm.jdo.PersistenceManagerFactoryUtils$PersistenceMa=
nagerSynchronization,
org.springframework.orm.ojb.OjbFactoryUtils$PersistenceBrokerSynchronizat=
ion)
also don't check first before calling unbindResource.
Does anybody know if this is a bug (i.e., spring should check) or what
sort of non-spring problems might cause this to occur?
Thanks,
Calvin
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/
_______________________________________________
Springframework-developer mailing list
Spr...@li...
https://lists.sourceforge.net/lists/listinfo/springframework-developer
|