ibatis-user-cs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Zarar Siddiqi" <zar...@gmail.com>
Subject Weird but reproducable problem which sets HttpContext to null
Date Sat, 26 Aug 2006 22:54:01 GMT
A couple days ago I posted an exception I was receiving seemingly
randomly when using IBatis:


I did some more research and got it to reproduce.  Here it is.


In my Global.asax, I kick-start a background process using the Timer
class.  This Timer class uses a delgate DoTimerBasedStuff() which is
called periodically. The DoTimerBasedStuff() method accesses two
different databases, MySQL and SQL Server.  Both are setup properly
using their MySQLMapper and SQLServerMapper classes.

Aside from a couple of these background threads, the application also
has a web front which accesses both databases using typical .aspx
pages and classes inherited from Page.  Nothing fancy.


If the application is started by going to index.aspx using a browser
(this page doesn't do any db stuff but triggers Global.asax) and no
other actions are taken until the first call of DoTimerBasedStuff()
all is well and both the background process and the web users are
fine.  IBatis does everything right.

BUT if I start the application by going to index.aspx and then
immediately do some work via the web which accesses a database (before
DoTimerBasedStuff() is executed), the DoTimerBasedStuff() method has
trouble accessing the HttpContext and gives the following error:

Exception: WebSessionStore: Could not obtain reference to HttpContext
  at IBatisNet.DataMapper.SessionStore.WebSessionStore.ObtainSessionContext()
  at IBatisNet.DataMapper.SessionStore.WebSessionStore.get_LocalSession()
  at IBatisNet.DataMapper.SqlMapper.QueryForObject(String

I guess the question that I should be asking is what is the best way
to run a background process/thread in a web application which uses
IBatis functionality.

Thanks in advance.

View raw message