Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-29546

Avoid Cannot use a CoreSession outside a transaction Exception

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Aspera Connector

      Description

      In some cases, mainly on Lis's test for PR-141. We saw in the logs some errors at

      org.nuxeo.ecm.core.api.NuxeoException: Cannot use a CoreSession outside a transaction
      	at org.nuxeo.ecm.core.api.local.LocalSession.getSession(LocalSession.java:106) ~[nuxeo-core-10.10-HF27.jar:?]
      	at org.nuxeo.ecm.core.api.AbstractSession.resolveReference(AbstractSession.java:337) ~[nuxeo-core-10.10-HF27.jar:?]
      	at org.nuxeo.ecm.core.api.AbstractSession.getDocument(AbstractSession.java:953) ~[nuxeo-core-10.10-HF27.jar:?]
      	at com.nuxeo.aspera.connector.service.AsperaNodeServiceImpl.syncTransfer(AsperaNodeServiceImpl.java:215) ~[nuxeo-aspera-core-3.0.0-SNAPSHOT-PR-141.jar:?]
      	at com.nuxeo.aspera.connector.events.CheckTransferredFilesAvailability.handleEvent(CheckTransferredFilesAvailability.java:66) [nuxeo-aspera-core-3.0.0-SNAPSHOT-PR-141.jar:?]
      	at org.nuxeo.ecm.core.event.impl.EventServiceImpl.fireEvent(EventServiceImpl.java:242) [nuxeo-core-event-10.10-HF30.jar:?]
      	at org.nuxeo.ecm.core.scheduler.EventJob.execute(EventJob.java:119) [nuxeo-core-event-10.10-HF30.jar:?]
      	at org.nuxeo.ecm.core.scheduler.EventJob.execute(EventJob.java:65) [nuxeo-core-event-10.10-HF30.jar:?]
      	at org.quartz.core.JobRunShell.run(JobRunShell.java:202) [quartz-2.3.0.jar:?]
      	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573) [quartz-2.3.0.jar:?]
      2020-08-12T21:30:08,097 WARN  [Quartz_Worker-1] [com.nuxeo.aspera.connector.events.CheckTransferredFilesAvailability] Error on transfer=f1c991ff-0173-4530-a56a-e3dc89a81f81
      org.nuxeo.ecm.core.api.NuxeoException: Cannot use a CoreSession outside a transaction
      	at org.nuxeo.ecm.core.api.local.LocalSession.getSession(LocalSession.java:106) ~[nuxeo-core-10.10-HF27.jar:?]
      	at org.nuxeo.ecm.core.api.AbstractSession.resolveReference(AbstractSession.java:337) ~[nuxeo-core-10.10-HF27.jar:?]
      	at org.nuxeo.ecm.core.api.AbstractSession.getDocument(AbstractSession.java:953) ~[nuxeo-core-10.10-HF27.jar:?]
      	at com.nuxeo.aspera.connector.service.AsperaNodeServiceImpl.syncTransfer(AsperaNodeServiceImpl.java:215) ~[nuxeo-aspera-core-3.0.0-SNAPSHOT-PR-141.jar:?]
      	at com.nuxeo.aspera.connector.events.CheckTransferredFilesAvailability.handleEvent(CheckTransferredFilesAvailability.java:66) [nuxeo-aspera-core-3.0.0-SNAPSHOT-PR-141.jar:?]
      	at org.nuxeo.ecm.core.event.impl.EventServiceImpl.fireEvent(EventServiceImpl.java:242) [nuxeo-core-event-10.10-HF30.jar:?]
      	at org.nuxeo.ecm.core.scheduler.EventJob.execute(EventJob.java:119) [nuxeo-core-event-10.10-HF30.jar:?]
      	at org.nuxeo.ecm.core.scheduler.EventJob.execute(EventJob.java:65) [nuxeo-core-event-10.10-HF30.jar:?]
      	at org.quartz.core.JobRunShell.run(JobRunShell.java:202) [quartz-2.3.0.jar:?]
      	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573) [quartz-2.3.0.jar:?]
      

      I didn't find a good way to reproduce, but we can try to avoid it by adding check on TX active in the finally block

        if (!TransactionHelper.isTransactionActive()) {
                      TransactionHelper.commitOrRollbackTransaction();
                      TransactionHelper.startTransaction();
         }
      

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 2 hours
                  2h