cancel
Showing results for 
Search instead for 
Did you mean: 

Can't generate picture thumbnails

Marwane_K_A_
Star Contributor
Star Contributor

Hi,

I'm getting the stacktrace below each time I upload a picture ; it must be a configuration issue since I'm only getting this on my pre-production server, but I don't get why.

ImageMagick is installed and can be launched by the user behind the Nuxeo process. "convert -version" returns:

Version: ImageMagick 6.6.9-7 2012-08-17 Q16 http://www.imagemagick.org
/> Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
/> Features: OpenMP

I'm using Nuxeo 5.7.1. Did anyone ever run into a similar error? Thanks

2013-06-25 17:55:31,655 ERROR [org.nuxeo.ecm.core.work.AbstractWork] Exception during work: PictureViewsGenerationWork(RUNNING, Progress(0.0%, ?/0), null)
org.nuxeo.ecm.core.api.ClientException: Failed to save document DocumentModelImpl(649ce38e-92f6-4d7f-9c49-432fb874b97b, path=/asset-library/Test Thumb, title=Test Thumb)
    at org.nuxeo.ecm.core.api.AbstractSession.saveDocument(AbstractSession.java:1989)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.nuxeo.ecm.core.api.TransactionalCoreSessionWrapper.invoke(TransactionalCoreSessionWrapper.java:133)
    at com.sun.proxy.$Proxy44.saveDocument(Unknown Source)
    at org.nuxeo.ecm.platform.picture.PictureViewsGenerationWork.work(PictureViewsGenerationWork.java:45)
    at org.nuxeo.ecm.core.work.AbstractWork.run(AbstractWork.java:164)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:722)
Caused by: org.nuxeo.ecm.core.api.DocumentException: org.nuxeo.ecm.core.storage.StorageException: java.io.IOException: Stream Closed
    at org.nuxeo.ecm.core.storage.sql.coremodel.SQLSession.getBinary(SQLSession.java:1154)
    at org.nuxeo.ecm.core.storage.sql.coremodel.SQLContentProperty.setValue(SQLContentProperty.java:80)
    at org.nuxeo.ecm.core.storage.sql.coremodel.SQLComplexProperty.setValue(SQLComplexProperty.java:101)
    at org.nuxeo.ecm.core.storage.sql.coremodel.SQLComplexListProperty.setList(SQLComplexListProperty.java:278)
    at org.nuxeo.ecm.core.storage.sql.coremodel.SQLComplexListProperty.setValue(SQLComplexListProperty.java:86)
    at org.nuxeo.ecm.core.storage.sql.coremodel.SQLComplexProperty.setPropertyValue(SQLComplexProperty.java:222)
    at org.nuxeo.ecm.core.storage.sql.coremodel.SQLDocumentLive.writeDocumentPart(SQLDocumentLive.java:178)
    at org.nuxeo.ecm.core.api.DocumentModelFactory.writeDocumentModel(DocumentModelFactory.java:298)
    at org.nuxeo.ecm.core.api.AbstractSession.writeModel(AbstractSession.java:541)
    at org.nuxeo.ecm.core.api.AbstractSession.saveDocument(AbstractSession.java:1961)
    ... 11 more
Caused by: org.nuxeo.ecm.core.storage.StorageException: java.io.IOException: Stream Closed
    at org.nuxeo.ecm.core.storage.sql.SessionImpl.getBinary(SessionImpl.java:315)
    at org.nuxeo.ecm.core.storage.sql.ra.ConnectionImpl.getBinary(ConnectionImpl.java:161)
    at org.nuxeo.ecm.core.storage.sql.coremodel.SQLSession.getBinary(SQLSession.java:1152)
    ... 20 more
Caused by: java.io.IOException: Stream Closed
    at java.io.FileInputStream.available(Native Method)
    at org.nuxeo.ecm.core.storage.sql.AbstractBinaryManager.storeAndDigest(AbstractBinaryManager.java:97)
    at org.nuxeo.ecm.core.storage.sql.LocalBinaryManager.storeAndDigest(LocalBinaryManager.java:176)
    at org.nuxeo.ecm.core.storage.sql.LocalBinaryManager.getBinary(LocalBinaryManager.java:114)
    at org.nuxeo.ecm.core.storage.sql.SessionImpl.getBinary(SessionImpl.java:313)
    ... 22 more
4 REPLIES 4

Marwane_K_A_
Star Contributor
Star Contributor

Hi,

Marwane_K_A_
Star Contributor
Star Contributor

I figured out that the bug is caused by the use of an InputStreamBlob to store temporarily the original picture ; the blob is somehow broken when time comes to save the document (maybe the stream is read before?).

I hacked it by overriding the PictureViewListener + PictureViewsGenerationWork, replacing the blob right after the thumbnails generation:

org.nuxeo.ecm.platform.picture.PictureViewsGenerationWork

        ...
        picture.fillPictureViews(blob, filename, title, pictureTemplates);
  
        // Fix original picture
        String originalContentXpath = picture.getViewXPath("Original") + "content";
        Serializable originalContent = workingDocument.getPropertyValue(originalContentXpath);
        if (originalContent instanceof InputStreamBlob) {
            InputStreamBlob originalContentBlob = (InputStreamBlob) originalContent;
            Blob persistedBlob = originalContentBlob.persist();
            workingDocument.setPropertyValue(originalContentXpath, (Serializable) persistedBlob);
        }

Hi,

Hi Thomas,