Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Problem with *servlet-started* update DSRequest that does no cacheSync

    Hi Isomorphic,

    I'm transitioning existing 5.1p (v10.1p_2016-04-12) server code that was used from the client to work from server/servlet use as well, making it not depend on a RPCManager-instance presence.

    Right now I'm seeing a problem where an update request if triggered from servlet, does not do a cacheSync after the successful update, while it does so when triggered from the client.
    The only difference I can see is that it has an RPCManager in the client-case, while it has no RPCManager but a DSTransaction in the servlet-case.

    I don't think this is on purpose. Can you have a look at the framework code here?
    If needed I can try to prepare a testcase.

    Thank you & Best regards
    Blama

    #2
    We'll definitely need a test case on this one, we don't see any framework code that could be responsible and we know you are using various settings to turn off cache sync in some circumstances - one of those is probably ending up applying in a circumstance where you didn't realize it would.

    Comment


      #3
      Hi Isomorphic,

      OK, I'll do so tomorrow.

      Thank you
      Blama

      Comment


        #4
        Hi Isomorphic,

        please see this v10.1p_2016-04-18 BuiltInDS based testcase:

        SupplyItemUpdateServlet.java:
        Code:
        package com.smartgwt.sample.server.listener;
        
        import java.io.IOException;
        import java.util.LinkedHashMap;
        
        import javax.servlet.ServletException;
        import javax.servlet.http.HttpServlet;
        import javax.servlet.http.HttpServletRequest;
        import javax.servlet.http.HttpServletResponse;
        
        import com.isomorphic.datasource.DSRequest;
        import com.isomorphic.datasource.DSResponse;
        import com.isomorphic.datasource.DSTransaction;
        import com.isomorphic.datasource.DataSource;
        
        public class SupplyItemUpdateServlet extends HttpServlet {
            private static final long serialVersionUID = 6052735004239581488L;
        
            @Override
            public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
                try {
                    doUpdate(request, response);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        
            @Override
            public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
                doGet(request, response);
            }
        
            private void doUpdate(HttpServletRequest request, HttpServletResponse response) throws Exception {
                DSTransaction dst = new DSTransaction();
                DSRequest updateRequest = new DSRequest("supplyItem", DataSource.OP_UPDATE);
                updateRequest.setDsTransaction(dst);
                updateRequest.addToCriteria(updateRequest.getDataSource().getPrimaryKey(), 1);
                LinkedHashMap<String, Object> vm = new LinkedHashMap<String, Object>();
                vm.put("itemName", "ITEM1");
                updateRequest.setValues(vm);
                DSResponse updateResponse = updateRequest.execute();
                response.getWriter().append(String.valueOf(updateResponse.getStatus()));
                response.getWriter().append("-" + String.valueOf(updateResponse.getAffectedRows()));
                if (updateResponse.getRecord() == null)
                    response.getWriter().append("-null");
                else
                    response.getWriter().append("-not null");
                dst.complete();
            }
        };
        web.xml addition:
        Code:
            <servlet>
                <servlet-name>SupplyItemUpdateServlet</servlet-name>
                <servlet-class>com.smartgwt.sample.server.listener.SupplyItemUpdateServlet</servlet-class>
            </servlet>
            <servlet-mapping>
                <servlet-name>SupplyItemUpdateServlet</servlet-name>
                <url-pattern>/SupplyItemUpdateServlet</url-pattern>
            </servlet-mapping>[B][/B]


        Calling http://127.0.0.1:8888/SupplyItemUpdateServlet results in: "0-1-null" and the server log shows no cacheSync Request:
        Code:
        === 2016-04-20 15:47:35,995 [1-32] INFO  RequestContext - URL: '/SupplyItemUpdateServlet', User-Agent: 'Mozilla/5.0 (Windows NT 6.3; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0': Moz (Gecko) with Accept-Encoding header
        === 2016-04-20 15:47:35,996 [1-32] DEBUG ISCKeyedObjectPool - Borrowing object for 'supplyItem'
        === 2016-04-20 15:47:35,996 [1-32] DEBUG PoolableDataSourceFactory - Activated DataSource 14 of type 'supplyItem'
        === 2016-04-20 15:47:35,997 [1-32] DEBUG DSRequest - Caching instance 14 of DS 'supplyItem' from DSRequest.getDataSource()
        === 2016-04-20 15:47:35,997 [1-32] DEBUG DSRequest - Caching instance 14 of DS supplyItem
        === 2016-04-20 15:47:35,997 [1-32] DEBUG DeclarativeSecurity - Processing security checks for DataSource null, field null
        === 2016-04-20 15:47:35,997 [1-32] DEBUG DeclarativeSecurity - Request is not a client request, ignoring security checks.
        === 2016-04-20 15:47:35,998 [1-32] DEBUG AppBase - [builtinApplication.null] No userTypes defined, allowing anyone access to all operations for this application
        === 2016-04-20 15:47:35,998 [1-32] DEBUG AppBase - [builtinApplication.null] No public zero-argument method named '_null' found, performing generic datasource operation
        === 2016-04-20 15:47:36,001 [1-32] INFO  SQLDataSource - [builtinApplication.null] Performing update operation with
            criteria: {itemID:1}    values: {itemName:"ITEM1"}
        === 2016-04-20 15:47:36,006 [1-32] DEBUG PoolableSQLConnectionFactory - [builtinApplication.null] Executing pingTest 'select 1 from dual' on connection 700092080
        === 2016-04-20 15:47:36,008 [1-32] DEBUG SQLConnectionManager - [builtinApplication.null] Borrowed connection '700092080'
        === 2016-04-20 15:47:36,008 [1-32] DEBUG SQLTransaction - [builtinApplication.null] Started new Oracle transaction "700092080"
        === 2016-04-20 15:47:36,009 [1-32] DEBUG SQLDataSource - [builtinApplication.null] Setting DSRequest as being part of a transaction
        === 2016-04-20 15:47:36,009 [1-32] INFO  SQLDriver - [builtinApplication.null] Executing SQL query on 'Oracle' using connection '700092080': UPDATE supplyItem SET itemName='ITEM1' WHERE (supplyItem.itemID=1)
        === 2016-04-20 15:47:36,010 [1-32] DEBUG SQLDataSource - [builtinApplication.null] update operation affected 1 rows
        === 2016-04-20 15:47:36,011 [1-32] DEBUG DSRequest - freeOnExecute is false for request of type update on DataSource supplyItem - not freeing resources!
        === 2016-04-20 15:47:36,011 [1-32] DEBUG SQLTransaction - Committing Oracle transaction "700092080"
        === 2016-04-20 15:47:36,012 [1-32] DEBUG SQLTransaction - getConnection() looked for transactional connection for Oracle:  hashcode "700092080"
        === 2016-04-20 15:47:36,012 [1-32] DEBUG SQLTransaction - Ending Oracle transaction "700092080"
        === 2016-04-20 15:47:36,012 [1-32] DEBUG SQLConnectionManager - About to close connection with hashcode "700092080"
        === 2016-04-20 15:47:36,013 [1-32] DEBUG PoolableSQLConnectionFactory - Executing pingTest 'select 1 from dual' on connection 700092080
        === 2016-04-20 15:47:36,014 [1-32] DEBUG PoolableSQLConnectionFactory - Passivating connection '700092080
        === 2016-04-20 15:47:36,014 [1-32] DEBUG SQLDataSource - About to clear SQLDriver state for DS instance 14
        === 2016-04-20 15:47:36,014 [1-32] DEBUG SQLDataSource - About to clear SQLDriver state for DS instance 14
        === 2016-04-20 15:47:36,014 [1-32] DEBUG SQLDataSource - About to clear SQLDriver state for DS instance 14
        === 2016-04-20 15:47:36,014 [1-32] DEBUG PoolableDataSourceFactory - Cleared and passivated DataSource 14 of type 'supplyItem'
        Best regards
        Blama

        Comment


          #5
          This is fixed and will be available for download in nightly builds since May 3 (today).

          Comment


            #6
            Hi Isomorphic,

            this is working in my application using v10.1p_2016-05-03.

            Thank you & Best regards
            Blama

            Comment

            Working...
            X