Re: Please help: retrieval and proper usage of per thread DataContext

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Wed Nov 30 2005 - 01:45:18 EST

  • Next message: Andrus Adamchik: "Re: Modeler - Names at singular after reverse engineering?"

    I confirmed - this is a bug in Jetty. I get the same results as you
    do on Jetty 5.1.3, while on Tomcat "requestInitialized" and
    "requestDestroyed" are being called just fine. Haven't tried Jetty 6
    yet.

    As a workaround that works on all servers with both servlet spec 2.3
    and 2.4, I suggest using WebApplicationContextFilter instead of the
    listener. Here is a snip from a sample web.xml

    <filter>
         <filter-name>CayenneFilter</filter-name>
         <filter-
    class>org.objectstyle.cayenne.conf.WebApplicationContextFilter</
    filter-class>
    </filter>
    <filter-mapping>
         <filter-name>CayenneFilter</filter-name>
         <url-pattern>/*</url-pattern>
    </filter-mapping>

    This is taken from Example #2 on Wiki:

    http://objectstyle.org/confluence/display/CAY/Cayenne+Examples)

    Andrus

    On Nov 30, 2005, at 3:45 AM, Joseph Hannon wrote:
    > Andrus,
    >
    > A little more testing- thanks for the debug tip! I subclassed
    > WebApplicationContextProvider and overrode all the relevant methods
    > including "requestInitialized" to allow dubug log statements.
    > "requestInitialized" is not called for some reason, but methods
    > around it are. My results are below. I upgraded to Jetty 5.1.6 to
    > see if that would help, it did not. Could try it in Tomcat to see
    > if there is any change, wouldn't expect a change. I may need to do
    > as you suggest with ServletUtil. I am also unaware of how to get
    > the session at that point.
    >
    > Joseph
    >
    > App startup:
    >
    > (main) DEBUG foo.bar.utility.DataContextProvider.<init>()
    > (main) DEBUG foo.bar.utility.DataContextProvider.contextInitialized()
    >
    > Going to Page 1 (reads from DB)
    >
    > (SunJsseListener1-1) DEBUG
    > foo.bar.utility.DataContextProvider.sessionCreated()
    > (SunJsseListener1-1) DEBUG
    > foo.bar.utility.DataContextProvider.getConfiguration()
    >
    > Submit Page 1
    > Going to Page 2 (reads from DB)
    > Submit Page 2 (writes to DB)
    >
    > (SunJsseListener1-0) DEBUG
    > foo.bar.utility.DataContextProvider.sessionDestroyed()
    >
    > Complete.
    >



    This archive was generated by hypermail 2.0.0 : Wed Nov 30 2005 - 01:45:21 EST