Hi!

ASP.NET does not guarantee that the whole request is processed in same
thread. Especially some async patterns ( Async attribute in @page directive,
async webservice calls etc) will cause thread agility.

IsWeb should take care of this if it is configured properly. Have you
implemented  a custom httpapplication that also implements
IContainerAccessor and made the required change to your global.asax?

See
http://docs.castleproject.org/Windsor.NHibernate-Facility.ashx


Tapio Kulmala

"Those are my principles, and if you don't like them... well, I have others"
- Groucho Marx

http://twitter.com/tapiokulmala
http://www.linkedin.com/in/tapiokulmala
http://profiles.google.com/tapiokulmala




On Wed, Jul 27, 2011 at 1:23 AM, Daragh <[email protected]> wrote:

> We are seeing a very strange problem with an ASP.NET application that
> was recently upgraded to NHibernate 3.10GA, Castle 2.5.2, and using
> Castle.Facilities.NHibernateIntegration. We are using ISessionManager
> from NHibernateIntegration with the Web.SessionWebModule component to
> manage our request response loop, and have it configured with
> isWeb=true.
>
> Our application returns a page for a url encoded parameter, and this
> page also subsequently makes some web-service calls.
>
> The problem happens very intermittently, and manifests itself as a
> NHibernate.LazyInitializationException - Could not initialize proxy -
> no Session error, caused by the lazy-loading of a many-to-one
> relationship from the main object. This would suggest that the session
> object is being lost while in the request-response loop for the page.
>
> We decided to debug the OnBeginRequest and OnEndRequest methods in
> Castle.Facilities.NHibernation, and added some debugging statements to
> identify the thread. What we found is the following:
>
> In the cases where there is an error, the threadId in the
> OnBeginRequest does not match the threadId in the OnEndRequest; and
> further it appears that the original thread is being used for other
> requests and responses. When the initial page request is finally
> returned it's threadid doesn't match the original threadid it was
> started in. Has anyone seen anything like this?
>
> Here's the debug data. Note the [9] indicates the originating thread
> according to log4net
>
> [9] DEBUG SessionWebModule - On begin request thread id: 9 for
> MyPage.aspx
> [9] DEBUG SessionWebModule - On begin request thread id: 9 for
> example.ashx
> [9] DEBUG SessionWebModule - On end request thread id: 9 example.ashx
> [9] DEBUG SessionWebModule - On begin request thread id: 9 for
> WebService.asmx/js
> [9] DEBUG SessionWebModule - On end request thread id: 9 for
> WebService.asmx/js
> [6] ERROR NHibernate.LazyInitializationException - [error message
> describing relationship] -Could not initialize proxy - no Session.
> [6] DEBUG SessionWebModule - On end request thread id: 9 for
> MyPage.aspx
>
>
> Note the first and last line showing that the page request originated
> in thread 9, but returned in thread 6.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Castle Project Development List" group.
> To post to this group, send email to [email protected]
> .
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/castle-project-devel?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Development List" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/castle-project-devel?hl=en.

Reply via email to