[JIRA] Created: (CAY-791) ThreadLocal bound DataContext is not obtainable in a multi-thread for a request environment such as ZK

From: Steve Wells (JIRA) ("Steve)
Date: Mon May 21 2007 - 04:32:43 EDT

  • Next message: Adrian Wiesmann: "Problem with DataFormat and XML Serialise/Deserialise"

    ThreadLocal bound DataContext is not obtainable in a multi-thread for a request environment such as ZK
    ------------------------------------------------------------------------------------------------------

                     Key: CAY-791
                     URL: https://issues.apache.org/cayenne/browse/CAY-791
                 Project: Cayenne
              Issue Type: Bug
              Components: Cayenne Core Library
        Affects Versions: 2.0 [STABLE], 3.0
             Environment: ZK Ajax framework and any other multi-thread per request environment
                Reporter: Steve Wells
             Assigned To: Andrus Adamchik

    Having hit my first roadblock now is getting DataContext, as each ZK request runs in a separate thread (see: http://www.zkoss.org/smalltalks/zkacegi/zkacegi.dsp ) I think this is the problem why I can't get DC with WebApplicationContextFilter and DataContext.getThreadDataContext (). I get "IllegalStateException: Current thread has no bound DataContext."
     
    Looking into src for DataContext I see this comment // TODO: Andrus, 11/7/2005 - should we use InheritableThreadLocal instead?
     
    So I subclassed DataContext and overrode the :
    ThreadLocal threadDataContext
     
    to be
     
    InheritableThreadLocal threadDataContext
     
    changed WebApplicationContextFilter to call my subclassed DataContext and it works.

    HOWEVER! This possible solution may be dangerous and currently needs more investigation.

    -- 
    This message is automatically generated by JIRA.
    -
    You can reply to this email to add a comment to the issue online.
    



    This archive was generated by hypermail 2.0.0 : Mon May 21 2007 - 04:33:10 EDT