data synch problem with cayenne 2.0.4.

From: Emanuele Maiarelli (emanuel..engozzi.com)
Date: Wed Mar 17 2010 - 09:59:50 EDT

  • Next message: Mike Kienenberger: "Re: Order By Expression"

    I found a data synchronization issue with cayenne 2.0.4

     

    The system consist in many swing applications interfacing with cayenne using
    ROPs. Plus a series of servelts that exposes data as XML or webservices.

     

    I found that an xml servlet was exposing a previous image of data, I
    verified that datas using the Swing/ROP client and they was updated.

     

    So inorder to verify the source of the problem I had to restart the servlet
    container (Tomcat, that contain the Hessian servlet too).

     

    As I restarted tomcat the XML data go in synch with both Database and
    swing/rop data.

     

    Then I started checking the servlet code and I found an error.

     

    Servelt processed data as follow:

     

    protected void processRequest(HttpServletRequest request,
    HttpServletResponse response)

        throws ServletException, IOException {

     response.setContentType("text/xml;charset=UTF-8");

    .

            HttpSession sess=request.getSession();

            DataContext dc= ServletUtil.getSessionContext(sess);

            String serviceType=request.getParameter("service");

    .

            try {

     

                CayenneServiceInterface serv = (CayenneServiceInterface)

     
    Class.forName("services.STT."+serviceType).newInstance();

                serv.setServletContext(getServletConfig().getServletContext());

     

                sb.append(serv.getData(dc, params));

     

            } catch (Exception ex) {

    .

        }

     

    So far servlet instance various objects implementing my
    CayenneServiceInterface interface, pass to instanced object a context
    obtained with DataContext dc= ServletUtil.getSessionContext(sess), so a
    session bound context, the instanced object elaborates the xml response.

     

    Looking into the specific object that created the inconsistent xml I found
    this error:

    The method serv.getData instead of using the DataContext obtained via
    ServletUtil.getSessionContext(sess), create a DataContext on spot

    .

    DataContext context = DataContext.createDataContext();

            List v = context.performQuery(q);

            Iterator it = v.iterator();

    .

     

    My question is if this error could lead to the inconsistency I found

     

    Thanks in advice,

     

     

    Emanuele

     

     

     

     

     

     



    This archive was generated by hypermail 2.0.0 : Wed Mar 17 2010 - 10:01:15 EDT