jamesfredley commented on issue #14333:
URL: https://github.com/apache/grails-core/issues/14333#issuecomment-3936343673

   Hi @arjangch - thanks for reporting this and for providing the sample app. 
We've identified the root cause and have a fix in PR #15425.
   
   **Root cause:** `GrailsOpenSessionInViewInterceptor` only opened a Hibernate 
session for the *default* datasource's `SessionFactory`. When `withSession` was 
called on a secondary datasource during a web request, 
`GrailsSessionContext.currentSession()` checked 
`TransactionSynchronizationManager` for the secondary `SessionFactory` but 
found nothing bound - hence the `No Session found for current thread` error.
   
   **Fix:** The OSIV interceptor now iterates all configured connection sources 
from the `HibernateDatastore` and opens/binds sessions for each non-default 
datasource alongside the default one. Sessions that are already bound (e.g. by 
a transaction) are left untouched.
   
   This also resolves the related issue #11798 (domain class on secondary 
datasource failing validation as a command object) since both share the same 
underlying cause.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to