When DAM is installed and a URL like the following is used to convert a jpeg (or png or gif) file for pdf preview, an exception occurs.
http://localhost:8080/nuxeo/api/v1/repo/default/id/fea463c9-f9eb-4eac-aecd-bddceb5f3528/@blob/blobholder:0/@convert?format=pdf
Exception:
org.nuxeo.ecm.core.api.NuxeoException: Cannot use a CoreSession outside a transaction at org.nuxeo.ecm.core.api.local.LocalSession.getSession(LocalSession.java:104) at org.nuxeo.ecm.core.api.AbstractSession.resolveReference(AbstractSession.java:336) at org.nuxeo.ecm.core.api.AbstractSession.getDataModel(AbstractSession.java:1948) at org.nuxeo.ecm.core.api.impl.DocumentModelImpl.loadDataModel(DocumentModelImpl.java:448) at org.nuxeo.ecm.core.api.impl.DocumentModelImpl.getDataModel(DocumentModelImpl.java:458) at org.nuxeo.ecm.core.api.impl.DocumentModelImpl.getPart(DocumentModelImpl.java:1219) at org.nuxeo.ecm.core.api.impl.DocumentModelImpl.getProperty(DocumentModelImpl.java:1267) at org.nuxeo.ecm.core.utils.BlobsExtractor.getBlobsProperties(BlobsExtractor.java:152) at org.nuxeo.ecm.core.utils.BlobsExtractor.getBlobs(BlobsExtractor.java:130) at org.nuxeo.ecm.core.api.blobholder.DocumentBlobHolder.getBlobs(DocumentBlobHolder.java:94) at org.nuxeo.ecm.platform.picture.convert.ConvertToPDFPictureConverter.convert(ConvertToPDFPictureConverter.java:47) at org.nuxeo.ecm.core.convert.service.ConversionServiceImpl.convert(ConversionServiceImpl.java:342) at org.nuxeo.ecm.core.convert.service.ConversionServiceImpl.convertToMimeType(ConversionServiceImpl.java:406) at org.nuxeo.ecm.restapi.server.jaxrs.adapters.ConvertAdapter.convertWithMimeType(ConvertAdapter.java:146) at org.nuxeo.ecm.restapi.server.jaxrs.adapters.ConvertAdapter.convertWithFormat(ConvertAdapter.java:157) at org.nuxeo.ecm.restapi.server.jaxrs.adapters.ConvertAdapter.convert(ConvertAdapter.java:83)
The issue is that the ConvertAdapter stops the transaction to not hold it open while potentially long work is going on, unfortunately to get to the blobs we need to read un-loaded datamodels from the document so have to read them from the session which cannot be used outside a transaction.
- duplicates
-
NXP-22255 Run conversions in the scope of a transaction
- Resolved