Announcement

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

    SQLTransaction warning

    SmartClient_SC_SNAPSHOT-2011-07-05 Power

    I have this DMI class which I use to download a report and to update a list of records (if everything goes well):
    Code:
    public class StampaEtichetteDMI {
    
    	@SuppressWarnings("unchecked")
    	public static DSResponse printLabel(DSRequest dsRequest, RPCManager rpcManager, HttpServletResponse httpServletResponse,
    			HttpServletRequest httpServletRequest) throws Exception {
    		SQLTransaction.startTransaction(rpcManager, "dbInviti");
    		try {
    			DSRequest dsRequestInvitiFetch = new DSRequest("INVITI", "fetch");
    			dsRequestInvitiFetch.setAdvancedCriteria(dsRequest.getAdvancedCriteria());
    			dsRequestInvitiFetch.setRPCManager(rpcManager); 
    			DSResponse dsResponseInvitiFetch = dsRequestInvitiFetch.execute();
    			List<Map<String, Object>> inviti = dsResponseInvitiFetch.getDataList();
    			updateDataStampaEtichette(rpcManager, inviti);
    			Servlets.downloadAsAttachment(httpServletResponse,
    					httpServletRequest.getServletContext().getResourceAsStream("./reports/report1.pdf"), "etichette.pdf");
    			httpServletResponse.getOutputStream().flush();
    			httpServletResponse.getOutputStream().close();
    			SQLTransaction.commitTransaction(rpcManager, "dbInviti");
    		} catch (Exception e) {
    			SQLTransaction.rollbackTransaction(rpcManager, "dbInviti");
    		} finally {
    			SQLTransaction.endTransaction(rpcManager, "dbInviti");
    		}
    		DSResponse dsResponse = new DSResponse();
    		rpcManager.doCustomResponse();
    		return dsResponse;
    	}
    
    	@SuppressWarnings("unchecked")
    	private static void updateDataStampaEtichette(RPCManager rpcManager, List<Map<String, Object>> inviti) throws Exception {
    		Map<String, Date> values = DataTools.buildMap("DATA_STAMPA_ETICHETTA", new Date());
    		for (Map<String, Object> invito : inviti) {
    			DSRequest dsRequestInvitiUpdate = new DSRequest("INVITI", "update");
    			dsRequestInvitiUpdate.setFieldValue("ID_INVITO", invito.get("ID_INVITO"));
    			dsRequestInvitiUpdate.setValues(values);
    			dsRequestInvitiUpdate.setRPCManager(rpcManager);
    			DSResponse dsResponseInvitiUpdate = dsRequestInvitiUpdate.execute();
    			dsResponseInvitiUpdate.getAffectedRows();
    		}
    	}
    
    }
    The report contains the data of the records filtered by the criteria, and I must set the sysdate for those records.
    It's my first attempt at managing a transaction server side.
    It seems to have got the correct behaviour, but I get this warning:
    server logs:
    Code:
    === 2011-07-13 15:56:04,000 [ec-4] INFO  IDACall - Performing 1 operation(s)
    === 2011-07-13 15:56:04,015 [ec-4] DEBUG PoolableSQLConnectionFactory - Returning pooled Connection
    === 2011-07-13 15:56:04,015 [ec-4] DEBUG SQLTransaction - Started new dbInviti transaction "17387626"
    startLabel: 1
    === 2011-07-13 15:56:04,031 [ec-4] DEBUG XML - Parsed XML from F:\iscSDK\tools\visualBuilder\workspace\Inviti\WebContent\shared\ds\INVITI.ds.xml: 0ms
    === 2011-07-13 15:56:04,031 [ec-4] DEBUG XML - Parsed XML from F:\iscSDK\tools\visualBuilder\workspace\Inviti\WebContent\isomorphic\system\schema\JS.ds.xml: 0ms
    === 2011-07-13 15:56:04,046 [ec-4] DEBUG XML - Parsed XML from F:\iscSDK\tools\visualBuilder\workspace\Inviti\WebContent\isomorphic\system\schema\Validator.ds.xml: 0ms
    === 2011-07-13 15:56:04,078 [ec-4] DEBUG AppBase - [builtinApplication.null] No userTypes defined, allowing anyone access to all operations for this application
    === 2011-07-13 15:56:04,078 [ec-4] DEBUG AppBase - [builtinApplication.null] No public zero-argument method named '_null' found, performing generic datasource operation
    === 2011-07-13 15:56:04,078 [ec-4] INFO  SQLDataSource - [builtinApplication.null] Performing update operation with
    	criteria: {ID_INVITO:1621}	values: {DATA_AGGIORNAMENTO:new Date(1310565364062),UTENTE_AGGIORNAMENTO:"cbosticco",DATA_STAMPA_ETICHETTA:new Date(1310565364015)}
    === 2011-07-13 15:56:04,093 [ec-4] INFO  SQLDriver - [builtinApplication.null] Executing SQL update on 'dbInviti': UPDATE INVITI SET DATA_AGGIORNAMENTO=TO_DATE('2011-07-13 15:56:04','YYYY-MM-DD HH24:MI:SS'), UTENTE_AGGIORNAMENTO='cbosticco', DATA_STAMPA_ETICHETTA=TO_DATE('2011-07-13 15:56:04','YYYY-MM-DD HH24:MI:SS') WHERE (INVITI.ID_INVITO='1621')
    === 2011-07-13 15:56:04,281 [ec-4] DEBUG SQLDataSource - [builtinApplication.null] update operation affected 1 rows
    === 2011-07-13 15:56:04,281 [ec-4] INFO  SQLDataSource - [builtinApplication.null] primaryKeys: {ID_INVITO=1621}
    === 2011-07-13 15:56:04,281 [ec-4] INFO  SQLDriver - [builtinApplication.null] Executing SQL query on 'dbInviti': SELECT INVITI.ID_CATEGORIA_ASSEGNATA_FK, INVITI.NUMERO_ACCOMPAGNATORI, INVITI.PARCHEGGIO_BOOL, INVITI.SOCIETA, INVITI.DIREZIONE, INVITI.TITOLO, INVITI.NOTE_PARCHEGGIO, INVITI.NAZIONE, INVITI.DATA_AGGIORNAMENTO, INVITI.ID_TRASFERIMENTO, INVITI.ID_INVITO, INVITI.LUOGO_ENTE_RILASCIO_DOCUMENTO, INVITI.CAP, INVITI.PROVINCIA, INVITI.CARICA, INVITI.MAILED_TO, INVITI.PARCHEGGIO, INVITI.LOCALITA, INVITI.ID_INTESTATARIO_BUSTA, INVITI.ID_CATEGORIA_DESIDERATA_FK, INVITI.UTENTE, INVITI.NUMERO_DOCUMENTO, INVITI.ACCOMMODATION_BOOL, INVITI.EMAIL_UFFICIO, INVITI.INDIRIZZO_DI_INVIO, INVITI.MAILED_SUBJECT, INVITI.DATA_STAMPA_ETICHETTA, TITOLO || ' ' || NOME || ' ' || COGNOME AS nominativo, INVITI.NOTE_ACCOMMODATION, INVITI.NOME, INVITI.UTENTE_AGGIORNAMENTO, INVITI.LUOGO_PROVINCIA_DI_NASCITA, INVITI.TELEFONI_UFFICIO, INVITI.NOTE_TRASFERIMENTO, INVITI.NOTE_RITIRO, INVITI.ESCLUSO, INVITI.DATA_DI_NASCITA, INVITI.ACCOMPAGNATORE_DI, INVITI.ID_GRUPPO_STAMPA, INVITI.DATA_SPEDIZIONE_EMAIL, INVITI.AREA_RIFERIMENTO_JUVENTUS, INVITI.ACCOMMODATION, INVITI.TIPO_DOCUMENTO, INVITI.ID_EVENTO_FK, INVITI.ID_MACRO_GRUPPO_FK, INVITI.MAILED_CC, INVITI.COGNOME, INVITI.TRASFERIMENTO, INVITI.QUALIFICA, INVITI.TELEFONI_ABITAZIONE, INVITI.MODALITA_RITIRO, INVITI.QUANTITA_PARCHEGGIO, INVITI.DATA_RECALL, INVITI.EMAIL_ABITAZIONE FROM INVITI WHERE (INVITI.ID_INVITO='1621')
    === 2011-07-13 15:56:04,296 [ec-4] INFO  DSResponse - [builtinApplication.null] DSResponse: List with 1 items
    === 2011-07-13 15:56:04,296 [ec-4] DEBUG AppBase - [builtinApplication.null] No userTypes defined, allowing anyone access to all operations for this application
    === 2011-07-13 15:56:04,296 [ec-4] DEBUG AppBase - [builtinApplication.null] No public zero-argument method named '_null' found, performing generic datasource operation
    === 2011-07-13 15:56:04,296 [ec-4] INFO  SQLDataSource - [builtinApplication.null] Performing update operation with
    	criteria: {ID_INVITO:1622}	values: {DATA_AGGIORNAMENTO:new Date(1310565364296),UTENTE_AGGIORNAMENTO:"cbosticco",DATA_STAMPA_ETICHETTA:new Date(1310565364015)}
    === 2011-07-13 15:56:04,296 [ec-4] INFO  SQLDriver - [builtinApplication.null] Executing SQL update on 'dbInviti': UPDATE INVITI SET DATA_AGGIORNAMENTO=TO_DATE('2011-07-13 15:56:04','YYYY-MM-DD HH24:MI:SS'), UTENTE_AGGIORNAMENTO='cbosticco', DATA_STAMPA_ETICHETTA=TO_DATE('2011-07-13 15:56:04','YYYY-MM-DD HH24:MI:SS') WHERE (INVITI.ID_INVITO='1622')
    === 2011-07-13 15:56:04,312 [ec-4] DEBUG SQLDataSource - [builtinApplication.null] update operation affected 1 rows
    === 2011-07-13 15:56:04,312 [ec-4] INFO  SQLDataSource - [builtinApplication.null] primaryKeys: {ID_INVITO=1622}
    === 2011-07-13 15:56:04,312 [ec-4] INFO  SQLDriver - [builtinApplication.null] Executing SQL query on 'dbInviti': SELECT INVITI.ID_CATEGORIA_ASSEGNATA_FK, INVITI.NUMERO_ACCOMPAGNATORI, INVITI.PARCHEGGIO_BOOL, INVITI.SOCIETA, INVITI.DIREZIONE, INVITI.TITOLO, INVITI.NOTE_PARCHEGGIO, INVITI.NAZIONE, INVITI.DATA_AGGIORNAMENTO, INVITI.ID_TRASFERIMENTO, INVITI.ID_INVITO, INVITI.LUOGO_ENTE_RILASCIO_DOCUMENTO, INVITI.CAP, INVITI.PROVINCIA, INVITI.CARICA, INVITI.MAILED_TO, INVITI.PARCHEGGIO, INVITI.LOCALITA, INVITI.ID_INTESTATARIO_BUSTA, INVITI.ID_CATEGORIA_DESIDERATA_FK, INVITI.UTENTE, INVITI.NUMERO_DOCUMENTO, INVITI.ACCOMMODATION_BOOL, INVITI.EMAIL_UFFICIO, INVITI.INDIRIZZO_DI_INVIO, INVITI.MAILED_SUBJECT, INVITI.DATA_STAMPA_ETICHETTA, TITOLO || ' ' || NOME || ' ' || COGNOME AS nominativo, INVITI.NOTE_ACCOMMODATION, INVITI.NOME, INVITI.UTENTE_AGGIORNAMENTO, INVITI.LUOGO_PROVINCIA_DI_NASCITA, INVITI.TELEFONI_UFFICIO, INVITI.NOTE_TRASFERIMENTO, INVITI.NOTE_RITIRO, INVITI.ESCLUSO, INVITI.DATA_DI_NASCITA, INVITI.ACCOMPAGNATORE_DI, INVITI.ID_GRUPPO_STAMPA, INVITI.DATA_SPEDIZIONE_EMAIL, INVITI.AREA_RIFERIMENTO_JUVENTUS, INVITI.ACCOMMODATION, INVITI.TIPO_DOCUMENTO, INVITI.ID_EVENTO_FK, INVITI.ID_MACRO_GRUPPO_FK, INVITI.MAILED_CC, INVITI.COGNOME, INVITI.TRASFERIMENTO, INVITI.QUALIFICA, INVITI.TELEFONI_ABITAZIONE, INVITI.MODALITA_RITIRO, INVITI.QUANTITA_PARCHEGGIO, INVITI.DATA_RECALL, INVITI.EMAIL_ABITAZIONE FROM INVITI WHERE (INVITI.ID_INVITO='1622')
    === 2011-07-13 15:56:04,343 [ec-4] INFO  DSResponse - [builtinApplication.null] DSResponse: List with 1 items
    === 2011-07-13 15:56:04,343 [ec-4] DEBUG SQLTransaction - Committing dbInviti transaction "17387626"
    === 2011-07-13 15:56:04,375 [ec-4] DEBUG SQLTransaction - Ending dbInviti transaction "17387626"
    2011-07-13 15:56:13,765 INFO [org.jasig.cas.ticket.registry.support.DefaultTicketRegistryCleaner] - <Beginning ticket cleanup.>
    2011-07-13 15:56:13,765 INFO [org.jasig.cas.ticket.registry.support.DefaultTicketRegistryCleaner] - <0 tickets found to be removed.>
    2011-07-13 15:56:13,765 INFO [org.jasig.cas.ticket.registry.support.DefaultTicketRegistryCleaner] - <Finished ticket cleanup.>
    === 2011-07-13 15:56:14,234 [izer] WARN  SQLDataSource - Exception while ending transaction connection
    java.lang.Exception: Could not find a DSRequest for a SQLDataSource in getConnection
    	at com.isomorphic.sql.SQLTransaction.getConnection(SQLTransaction.java:148)
    	at com.isomorphic.sql.SQLDataSource.freeResources(SQLDataSource.java:2278)
    	at com.isomorphic.datasource.DSRequest.freeResources(DSRequest.java:3027)
    	at com.isomorphic.datasource.DSRequest.finalize(DSRequest.java:1988)
    	at java.lang.ref.Finalizer.invokeFinalizeMethod(Native Method)
    	at java.lang.ref.Finalizer.runFinalizer(Finalizer.java:83)
    	at java.lang.ref.Finalizer.access$100(Finalizer.java:14)
    	at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:160)
    I have:
    sql.dbInviti.autoJoinTransactions: true
    setting in server.properties.
    what am I doing wrong?
    Last edited by claudiobosticco; 13 Jul 2011, 13:39.

    #2
    You're doing manual transaction management, so in this instance, you want to disable auto-joining transactions on the RPCManager - just for this request - add an RPCManager to your DMI method's arguments to get access to it.

    Comment


      #3
      I've just tried adding:
      dsRequest.setJoinTransaction(false);

      as the first line in my DMI method, but I get this warning:
      Request processing has started; join transactions setting cannot be changed

      I've also tried:
      rpcManager.setTransactionPolicy(TransactionPolicy.NONE);

      but I get a similar warning:
      Queue processing has started; transaction policy cannot be changed

      what am I doing wrong?

      Comment


        #4
        Sorry, to clarify, two ways to do this:

        1. don't manually initiate a transaction, one is already ongoing. Instead, for your manually created dsRequests, call setJoinTransaction(true) and setRPCManager() with the current RPCManager. No calls to SQLTransaction at all, it's automatic. This is the preferred approach.

        2. disable automatic transactions via RPCManager.setTransactionPolicy(), but this must be done before any DSRequests start executing, so for example, in a replacement IDACall servlet. Then manually manage the transaction as you are doing below.

        Comment


          #5
          I'm trying approach n. 1:
          - as you can see in my sample code, I already have a RPCManager parameter
          - I already set it on my manually created dsRequests
          - I've removed every SQLTransaction operation
          - I've added setJoinTransactions (btw I have got autoJoinTransactions: true in server.properties)

          my new sample code is:
          Code:
          	public static DSResponse printLabel(DSRequest dsRequest, RPCManager rpcManager, HttpServletResponse httpServletResponse,
          			HttpServletRequest httpServletRequest) throws Exception {
          		DSRequest dsRequestInvitiFetch = new DSRequest("INVITI", "fetch");
          		dsRequestInvitiFetch.setJoinTransaction(true);
          		dsRequestInvitiFetch.setAdvancedCriteria(dsRequest.getAdvancedCriteria());
          		dsRequestInvitiFetch.setRPCManager(rpcManager);
          		DSResponse dsResponseInvitiFetch = dsRequestInvitiFetch.execute();
          		List<Map<String, Object>> inviti = dsResponseInvitiFetch.getDataList();
          		updateDataStampaEtichette(rpcManager, inviti);
          		Servlets.downloadAsAttachment(httpServletResponse,
          				httpServletRequest.getServletContext().getResourceAsStream("./reports/report1.pdf"), "etichette.pdf");
          		httpServletResponse.getOutputStream().flush();
          		httpServletResponse.getOutputStream().close();
          		SQLTransaction.commitTransaction(rpcManager, "dbInviti");
          		DSResponse dsResponse = new DSResponse();
          		rpcManager.doCustomResponse();
          		return dsResponse;
          	}
          
          	@SuppressWarnings("unchecked")
          	private static void updateDataStampaEtichette(RPCManager rpcManager, List<Map<String, Object>> inviti) throws Exception {
          		Map<String, Date> values = DataTools.buildMap("DATA_STAMPA_ETICHETTA", new Date());
          		for (Map<String, Object> invito : inviti) {
          			DSRequest dsRequestInvitiUpdate = new DSRequest("INVITI", "update");
          			dsRequestInvitiUpdate.setJoinTransaction(true);
          			dsRequestInvitiUpdate.setFieldValue("ID_INVITO", invito.get("ID_INVITO"));
          			dsRequestInvitiUpdate.setValues(values);
          			dsRequestInvitiUpdate.setRPCManager(rpcManager);
          			DSResponse dsResponseInvitiUpdate = dsRequestInvitiUpdate.execute();
          			dsResponseInvitiUpdate.getAffectedRows();
          		}
          	}
          but I get the same warning...

          Comment

          Working...
          X