Uploaded image for project: 'iBatis for .NET'
  1. iBatis for .NET
  2. IBATISNET-279

Cannot run iBatis query from timer handler

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Invalid
    • None
    • DataMapper 1.6.2
    • DataMapper
    • None
    • .NET 3.5, Windows 2003 Server

    Description

      I'm running an iBatis query within a Timer's Elapsed handler and I'm getting the following exception:

      IBatisNet.Common.Exceptions.IBatisNetException was unhandled by user code
      Message="WebSessionStore: Could not obtain reference to HttpContext"
      Source="IBatisNet.DataMapper"
      StackTrace:
      at IBatisNet.DataMapper.SessionStore.WebSessionStore.ObtainSessionContext()
      at IBatisNet.DataMapper.SessionStore.WebSessionStore.get_LocalSession()
      at IBatisNet.DataMapper.SqlMapper.QueryForList[T](String statementName, Object parameterObject)
      :
      :
      at System.Timers.Timer.MyTimerCallback(Object state)
      InnerException

      After looking through the code, I found two places where this exception is thrown. Both look like:

      private static HttpContext ObtainSessionContext()
      {
      HttpContext currentContext = HttpContext.Current;

      if (currentContext == null)

      { throw new IBatisNetException("WebSessionStore: Could not obtain reference to HttpContext"); }

      return currentContext;
      }

      Attachments

        Activity

          People

            gilles Gilles Bayon
            tim.j.stewart Tim Stewart
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: