tag:blogger.com,1999:blog-15346558.post2484684648275949640..comments2023-10-20T01:31:06.725-07:00Comments on Mac's Thoughts: Notes on Spring's OpenSessionInViewFilter and Hibernate's LazyInitializationExceptionMac Nolandhttp://www.blogger.com/profile/07086101163818736928noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-15346558.post-51411760711570939742014-01-09T17:05:45.277-08:002014-01-09T17:05:45.277-08:00Coming in late here, but...
Yes, there are a coup...Coming in late here, but...<br /><br />Yes, there are a couple of scenarios where Spring keeps global state that will kill you if you have more than one Spring context loaded. The multiple contexts will stomp all over each other's globals. This *is* documented, but there's also documentation showing you how to load multiple contexts that does *not* warn you about these cases, so it's a pretty easy trap to fall into.<br /><br />The two cases that I know of are the ThreadLocal variables used to bind the Hibernate Session to the transaction manager, and anything injected into AspectJ aspects. I've blogged about this in more detail here: http://lagod.id.au/blog/?p=266Unknownhttps://www.blogger.com/profile/17768549782306436177noreply@blogger.comtag:blogger.com,1999:blog-15346558.post-80088094059082488092013-09-14T14:24:43.662-07:002013-09-14T14:24:43.662-07:00Interesting observation. I got stuck at: 'ins...Interesting observation. I got stuck at: 'instantiating Spring twice'. What do you mean by it? what was the configuration you were using to do so? And what did you change to make it a single instance?<br />I am trying to work-around this to dynamically change the datasource in controller and adopt for transactional services.<br />Thanks,<br />PrabhakarRaohttps://www.blogger.com/profile/13757071571525004608noreply@blogger.com