You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Emanuele Maiarelli <em...@mengozzi.com> on 2010/03/17 14:59:50 UTC

data synch problem with cayenne 2.0.4.

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