Improving TIFF preview in Alfresco Share

In my experience I’ve noticed that one of the great features of Alfresco Share that is really appreciated by the users is the documents preview in the document library page. Recently I came across some TIFF documents whose preview quality was rather poor if not completely unusable. This was caused by ImageMagick doing a ugly conversion of multi-page TIFFs to PNGs. This article explains how to tweak Alfresco 3.3.x to get a better preview of multi-page TIFF documents in Share customizing the Alfresco transformers and using the last version of ImageMagick.

How the preview works

The preview mechanism is as simple as astonishing:

  • a Flash player embedded within the preview page is used to render some SWF content that represents the document to be previewed
  • the SWF content is dynamically retrieved from Alfresco by calling a webscript given the document node reference
  • when that webscript is called, it creates an SWF node through a chain of transformations from the document format to application/x-shockwave-flash
  • the SWF node is then stored as a child of the document node for further retrieval so that transformations are not unecessarily repeated
  • eventually, the webscript will send the SWF content back to the caller

I drew a simple sequence diagram that can help understand the interactions.
Trasnformations sequence diagram

This is what happens with document formats except for SWF documents and images (jpeg, gif, png, etc.), in which case the document content is returned as is (no conversion is needed for the Flash player to render those formats).

If you use Firebug to analyze the HTTP requests when the preview page is loaded you’ll see that urls follow this pattern depending on the document type:

  • for jpg, png and gif images: http://localhost:8080/share/proxy/alfresco/api/node/workspace/SpacesStore/fca7a769-5eea-4607-960d-de7f82382e98/content?c=force
  • for all other image formats: http://localhost:8080/share/proxy/alfresco/api/node/workspace/SpacesStore/19f7e50c-d16f-48fe-9851-b8b125d9a0b3/content/thumbnails/imgpreview?c=force
  • for all other formats but SWF: http://localhost:8080/share/proxy/alfresco/api/node/workspace/SpacesStore/19f7e50c-d16f-48fe-9851-b8b125d9a0b3/content/thumbnails/webpreview?c=force

All these requests are forwarded by Share’s proxy to the same webscript org/alfresco/cmis/content.get (see description at http://localhost:8080/alfresco/s/script/org/alfresco/cmis/content.get). As the description states, it streams the content of the specified document or its rendition:

  1. for images like jpg, png and gif no rendition takes place at all and document content is streamed as is
  2. for all other images, the document is converted to PNG: this is what happens by default with TIFF files
  3. in the last case, the document is converted to SWF

Since conversions of images in Alfresco are done by ImageMagick I supposed that this was the reason of the poor conversion of multi-page TIFFs to PNGs. In fact, I did some tests with the convert command and I found that I was using an old version of ImageMagick: 6.2.8 (RedHat Enterprise 5.4 comes with this package only). Anyway, I also did some tests on Windows with a more recent version of ImageMagick (6.5.7) and the best I could get was the preview of the first page of a multi-page TIF image. ImageMagick generates several files – one per page – from a single multi-page TIF file; I’m not completely sure, but I guess this is not what Alfresco expects.

From TIF to SWF

Anyway, I knew that Alfresco uses OpenOffice to convert documents into PDF files and Swftools to convert PDFs into SWFs; I supposed that if TIFF files could have been converted into PDFs then they could be transformed to SWFs as well. I had to figure out:

  • how to convert a multi-page TIF to PDF using some command line tool
  • how to configure Alfresco to convert TIF to PDF and then to SWF
  • how to tell Share to treat TIF files as other document formats

The answer to the first problem came soon when I tried a recent version of ImageMagick (6.6.4) to transform TIF files straight to PDF: in this case ImageMagick does a very good job and produces just one output file.

Understanding every single detail of a software is not always necessary in order to apply small changes, and this was the case. In a few minutes I wrote some xml files, changed a Javascript file in Share and start the whole thing up. And it worked!

The whole point is to learn how transformations are done in Alfresco: this is rather easy to do because every Alfresco component is injected and configured by Spring. Spring simplifies the definition and construction of components and makes it very easy to read how components are related to each other without even knowing what components do.

As always, the first step is to open the folder $TOMCAT_HOME/webapps/alfresco/WEB-INF/classes/alfresco and start reading some xml files that describe the transformation components (hint: search for files that contain the word transformer). You’ll see that at least two files define most of the transformers: content-services-context.xml and swf-transform-context.xml. I’m not going to drill down each transformer that is defined there because this will take too long but if you are interested I really suggest you to open these files and read the source code of referenced Java classes: you’ll see how easy the rendition mechanism is.

You may know that starting from version 3.2 Alfresco has the concept of subsystems. Subsystems are a very elastic way of configuring Spring beans and semplify extension and override. However, this is a very tough topic and it would deserve a separate post, so please refer to Alfresco documentation for a general overview of subsystems.

Alfresco transformers somehow rely on the subsystem mechanism. There’re two types of transformers (using my own terminology):

  • simple trasnformers, these do the hard job of transforming content from one format to another
  • complex transformers, these are built on top simple transformers to create a chain of transformations

Those of the first kind are configured through some sort of subsystem while those of the second kind are configured via the old way (in one of the two XML files I mentioned before).

We’re going to declare a complex transformer that explicitly converts from image/tiff format to application/x-shockwave-flash. This one in turn will rely on two simple transformers to perform a chain of renditions to application/pdf and to application/x-shockwave-flash.

We start defining a Spring context file under $TOMCAT_HOME/webapps/alfresco/WEB-INF/classes/alfresco/extension, lets call it tiff-transform-context.xml:

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
   <!-- Import the imagemagick transformer worker from the third party subsystem -->
   <bean id="transformer.worker.Tiff2pdf" class="org.alfresco.repo.management.subsystems.SubsystemProxyFactory">
      <property name="sourceApplicationContextFactory">
         <ref bean="thirdparty" />
      </property>
      <property name="sourceBeanName">
         <value>transformer.worker.Tiff2pdf</value>
      </property>
      <property name="interfaces">
         <list>
            <value>org.alfresco.repo.content.transform.ContentTransformerWorker</value>
         </list>
      </property>
   </bean>

   <bean id="transformer.Tiff2pdf" class="org.alfresco.repo.content.transform.ProxyContentTransformer"
      parent="baseContentTransformer">
      <property name="worker">
         <ref bean="transformer.worker.Tiff2pdf"/>
      </property>
   </bean>

   <bean id="transformer.complex.Tiff2swf"
        class="org.alfresco.repo.content.transform.ComplexContentTransformer"
        parent="baseContentTransformer" >
      <property name="transformers">
         <list>
            <ref bean="transformer.Tiff2pdf" />
            <ref bean="transformer.Pdf2swf" />
         </list>
      </property>
      <property name="intermediateMimetypes">
         <list>
            <value>application/pdf</value>
         </list>
      </property>
      <property name="explicitTransformations">
         <list>
         	<bean class="org.alfresco.repo.content.transform.ExplictTransformationDetails" >
                <property name="sourceMimetype"><value>image/tiff</value></property>
                <property name="targetMimetype"><value>application/x-shockwave-flash</value></property>
            </bean>
         </list>
      </property>
   </bean>
 </beans>

Now a bit of explanation about the beans involved here:

  • transformer.complex.Tiff2swf defines the complex transformer that defines the chain of transformers
  • transformer.Tiff2pdf represents the transformer from TIFF to PDF; actually this ia proxy that relies on the bean declared in the thirdparty subsystem
  • transformer.worker.Tiff2pdf is a sort of placeholder for that bean
  • transformer.Pdf2swf is the transformer from PDF to SWF and is defined by default in Alfresco (provided that you install Swftools and configure it in Alfresco)

Then we need to extend the thirdparty subsystem. Creates the folder $TOMCAT_HOME/webapps/alfresco/WEB-INF/classes/alfresco/extension/subsystems/thirdparty/default/default and add two files:

  • tiff-transform-context.xml
  • tiff-transform.properties

This is the content of tiff-transform-context.xml:

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
    <bean id="transformer.worker.Tiff2pdf" class="org.alfresco.repo.content.transform.RuntimeExecutableContentTransformerWorker">
      <property name="mimetypeService">
         <ref bean="mimetypeService" />
      </property>
      <property name="checkCommand">
         <bean class="org.alfresco.util.exec.RuntimeExec">
            <property name="commandMap">
                <map>
                    <entry key=".*">
                        <value>${img.exe} -version</value>
                    </entry>
                </map>
            </property>
         </bean>
      </property>
      <property name="transformCommand">
         <bean class="org.alfresco.util.exec.RuntimeExec">
            <property name="commandMap">
                <map>
                    <entry key=".*">
                        <value>${img.exe} ${source} ${target}</value>
                    </entry>
                </map>
            </property>
            <property name="errorCodes">
               <value>1</value>
            </property>
         </bean>
      </property>
      <property name="explicitTransformations">
         <list>
         	<bean class="org.alfresco.repo.content.transform.ExplictTransformationDetails" >
                <property name="sourceMimetype"><value>image/tiff</value></property>
                <property name="targetMimetype"><value>application/pdf</value></property>
            </bean>
         </list>
      </property>
   </bean>
 </beans>

Here is the content of tiff-transform.properties:

# External executable locations
img.exe=${img.root}/bin/convert

Transformer transformer.worker.Tiff2pdf is responsable for transforming a document using the ${img.exe} command; the value of ${img.exe} is set inside tiff-transform.properties where we reference the variable ${img.root} (which in turn is set in alfresco-global.properties). This transformer explicitly handles transformations from image/tiff to application/x-shockwave-flash.

The last thing to do now is to fix Share to make it request the SWF preview instead of the PNG thumbnail. This can be done easily by modifying the file web-preview.js under $TOMCAT_HOME/webapps/share/components/preview. Find method _resolvePreview and change it like this:

      _resolvePreview: function WP__resolvePreview(event)
      {
         var ps = this.options.previews,
            webpreview = "webpreview", imgpreview = "imgpreview",
            nodeRefAsLink = this.options.nodeRef.replace(":/", ""),
            argsNoCache = "?c=force&noCacheToken=" + new Date().getTime(),
            preview, url;
         
         if (this.options.mimeType.match(/^image\/jpeg$|^image\/png$|^image\/gif$/))         
         {
            /* The content matches an image mimetype that the web-previewer can handle without a preview */
            url = Alfresco.constants.PROXY_URI + "api/node/" + nodeRefAsLink + "/content" + argsNoCache;
            return (
            {
               url: url,
               paging: false
            });
         }
         else if (this.options.mimeType.match(/application\/x-shockwave-flash/))
         {
            url = Alfresco.constants.PROXY_URI + "api/node/content/" + nodeRefAsLink + argsNoCache + "&a=true";
            return (
            {
               url: url,
               paging: false
            });
         }
         else
         {
            if (this.options.mimeType.match(/^image\/tiff$/))
                preview = webpreview;
            else
                preview = Alfresco.util.arrayContains(ps, webpreview) ? webpreview : (Alfresco.util.arrayContains(ps, imgpreview) ? imgpreview : null);
            if (preview !== null)
            {
               url = Alfresco.constants.PROXY_URI + "api/node/" + nodeRefAsLink + "/content/thumbnails/" + preview + argsNoCache;
               return (
               {
                  url: url,
                  paging: true
               });
            }
            return null;
         }
      },

Once you have applied your changes, restart Alfresco, enter Share, refresh the preview page (make sure that browser cache is cleaned) and multi-page TIFFs should be previewed correctly.

Some news

The embedded SWF player in Share is SWFObject, a project that has now moved to Google Code.

The sequence diagram was drawn with Gliffy.

Leave a comment ?

32 Comments.

  1. Thanks!!!!
    I’m grateful with this article!!!!!
    It is useful
    thanks again

  2. Fabio Strozzi

    Glad you found it useful.
    Cheers.
    Fabio

  3. Your first xml code block – you say “We start defining this file under $TOMCAT_HOME/webapps/alfresco/WEB-INF/classes/alfresco/extension:” but it is not clear what this should be called – or am I missing something?

    • Hi gnyce,
      yes you’re right, I just missed it.
      Anyway, you can call it following the *-context.xml pattern of the spring configuration files in Alfresco. Lets call it tiff-transform-context.xml.

      Thanks for pointing it out.

      Cheers

      Fabio

  4. Hello,

    This is very usefull, I’ve made a similar thing for 3.0c Alfresco, except that I moved my transformer (built similarly to this one) to the extension (so $TOMCAT_HOME/shared/classes/alfresco/extension instead of the webapps).
    So now after upgrade, I had to do it again. Followed your instructions (except that I put it in the extension) this time, and it works!

    Thanks

    • Hi, thanks for your feedback, I’m glad to hear someone found it useful.
      Actually I don’t know why I wrote to add the extension files under the webapps folder, I usually work under the shared folder, just like you suggest.
      So, you’re right about it, the shared folder is right place to put extensions (except for some rare cases).

      Fabio

  5. Thank you SO much for posting this, full multipage tiff preview is much needed.

    I’ve also moved the two files to the TOMCAT_HOME/SHARED/classes/alfresco/extension, and called them tiff2pdf/tiff2swf-transform-context.xml respectively.

    For the linux users, you can also do something like this and it will not only speed it up, but HUGE memory savings (I was seeing 600MB per image conversion, this gets it down to 10-80MB per image conversion):
    alfresco-global.properties

    tiff2pdf.exe=/usr/bin/tiff2pdf

    tiff2pdf-transform-context.xml

    ....

    ....

    ${tiff2pdf.exe} -version

    ....

    ....
    ${tiff2pdf.exe} ${source} -o ${target}
    ...

    The only issue I’ve had with this approach is poor TIFF encoding may cause it to stop and not allow the preview to finish, but I’ve had similar issues with ImageMagick anyway.

    Hope this helps as much as this post has helped me!
    -D

    • Fabio Strozzi

      Hi, thanks for your feedback and your suggestion.
      I’ve never used tiff2pdf before but I’ll surely try it next time I configure Alfresco.
      Regards
      Fabio

    • I wasn’t having any success with the original description on how to get this to work so I tried moving the two files to the suggested “TOMCAT_HOME/SHARED/classes/alfresco/extension, and called them tiff2pdf/tiff2swf-transform-context.xml respectively” and also moved the properties file with them renaming it tiff2pdf-transform.properties and i get the below errors when attempting to preview an image:

      An error has occured in the Share component: /share/service/components/preview/web-preview.
      It responded with a status of 500 – Internal Error.
      Error Code Information: 500 – An error inside the HTTP server which prevented it from fulfilling the request.
      Error Message: 05200000 Failed to process template org/alfresco/components/preview/web-preview.get.html.ftl
      Server: Alfresco Spring WebScripts – v1.0.0 (Release Candidate 2 744) schema 1,000
      Time: Jun 20, 2011 1:13:39 PM
      Click here to view full technical information on the error.
      Exception: freemarker.template.TemplateException – Expected collection or sequence. node.previews evaluated instead to freemarker.template.SimpleHash on line 10, column 22 in org/alfresco/components/preview/web-preview.get.html.ftl.
      freemarker.core.TemplateObject.invalidTypeException(TemplateObject.java:135)
      freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:190)
      freemarker.core.Environment.visit(Environment.java:417)
      freemarker.core.IteratorBlock.accept(IteratorBlock.java:102)
      freemarker.core.Environment.visit(Environment.java:210)
      freemarker.core.MixedContent.accept(MixedContent.java:92)
      freemarker.core.Environment.visit(Environment.java:210)
      freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:79)
      freemarker.core.Environment.visit(Environment.java:210)
      freemarker.core.MixedContent.accept(MixedContent.java:92)
      freemarker.core.Environment.visit(Environment.java:210)
      freemarker.core.Environment.process(Environment.java:190)
      org.springframework.extensions.webscripts.processor.FTLTemplateProcessor.process(FTLTemplateProcessor.java:171)
      org.springframework.extensions.webscripts.AbstractWebScript.renderTemplate(AbstractWebScript.java:589)
      org.springframework.extensions.webscripts.DeclarativeWebScript.renderFormatTemplate(DeclarativeWebScript.java:267)
      org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:147)
      org.springframework.extensions.webscripts.PresentationContainer.executeScript(PresentationContainer.java:69)
      org.springframework.extensions.webscripts.LocalWebScriptRuntimeContainer.executeScript(LocalWebScriptRuntimeContainer.java:231)
      org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:333)
      org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:189)
      org.springframework.extensions.webscripts.WebScriptProcessor.executeBody(WebScriptProcessor.java:284)
      org.springframework.extensions.surf.render.AbstractProcessor.execute(AbstractProcessor.java:57)
      org.springframework.extensions.surf.render.RenderService.processComponent(RenderService.java:264)
      org.springframework.extensions.surf.render.bean.ComponentRenderer.body(ComponentRenderer.java:93)
      org.springframework.extensions.surf.render.AbstractRenderer.render(AbstractRenderer.java:75)
      org.springframework.extensions.surf.render.RenderService.renderComponent(RenderService.java:600)
      org.springframework.extensions.surf.render.RenderService.renderRegionComponents(RenderService.java:539)
      org.springframework.extensions.surf.render.RenderService.renderChromeInclude(RenderService.java:893)
      org.springframework.extensions.webscripts.ChromeIncludeFreeMarkerDirective.execute(ChromeIncludeFreeMarkerDirective.java:71)
      freemarker.core.Environment.visit(Environment.java:263)
      freemarker.core.UnifiedCall.accept(UnifiedCall.java:126)
      freemarker.core.Environment.visit(Environment.java:210)
      freemarker.core.MixedContent.accept(MixedContent.java:92)
      freemarker.core.Environment.visit(Environment.java:210)
      freemarker.core.Environment.process(Environment.java:190)
      org.springframework.extensions.webscripts.processor.FTLTemplateProcessor.process(FTLTemplateProcessor.java:171)
      org.springframework.extensions.webscripts.WebTemplateProcessor.executeBody(WebTemplateProcessor.java:345)
      org.springframework.extensions.surf.render.AbstractProcessor.execute(AbstractProcessor.java:57)
      org.springframework.extensions.surf.render.RenderService.processRenderable(RenderService.java:186)
      org.springframework.extensions.surf.render.bean.ChromeRenderer.body(ChromeRenderer.java:89)
      org.springframework.extensions.surf.render.AbstractRenderer.render(AbstractRenderer.java:75)
      org.springframework.extensions.surf.render.bean.ChromeRenderer.render(ChromeRenderer.java:80)
      org.springframework.extensions.surf.render.bean.RegionRenderer.body(RegionRenderer.java:92)
      org.springframework.extensions.surf.render.AbstractRenderer.render(AbstractRenderer.java:75)
      org.springframework.extensions.surf.render.RenderService.renderRegion(RenderService.java:492)
      org.springframework.extensions.webscripts.RegionFreemarkerTagDirective.execute(RegionFreemarkerTagDirective.java:75)
      freemarker.core.Environment.visit(Environment.java:263)
      freemarker.core.UnifiedCall.accept(UnifiedCall.java:126)
      freemarker.core.Environment.visit(Environment.java:210)
      freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:79)
      freemarker.core.Environment.visit(Environment.java:210)
      freemarker.core.MixedContent.accept(MixedContent.java:92)
      freemarker.core.Environment.visit(Environment.java:210)
      freemarker.core.Environment.visit(Environment.java:395)
      freemarker.core.BodyInstruction.accept(BodyInstruction.java:93)
      freemarker.core.Environment.visit(Environment.java:210)
      freemarker.core.MixedContent.accept(MixedContent.java:92)
      freemarker.core.Environment.visit(Environment.java:210)
      freemarker.core.Macro$Context.runMacro(Macro.java:172)
      freemarker.core.Environment.visit(Environment.java:603)
      freemarker.core.UnifiedCall.accept(UnifiedCall.java:106)
      freemarker.core.Environment.visit(Environment.java:210)
      freemarker.core.MixedContent.accept(MixedContent.java:92)
      freemarker.core.Environment.visit(Environment.java:210)
      freemarker.core.Environment.process(Environment.java:190)
      org.springframework.extensions.webscripts.processor.FTLTemplateProcessor.process(FTLTemplateProcessor.java:171)
      org.springframework.extensions.webscripts.WebTemplateProcessor.executeBody(WebTemplateProcessor.java:345)
      org.springframework.extensions.surf.render.AbstractProcessor.execute(AbstractProcessor.java:57)
      org.springframework.extensions.surf.render.RenderService.processTemplate(RenderService.java:378)
      org.springframework.extensions.surf.render.bean.TemplateInstanceRenderer.body(TemplateInstanceRenderer.java:123)
      org.springframework.extensions.surf.render.AbstractRenderer.render(AbstractRenderer.java:75)
      org.springframework.extensions.surf.render.bean.PageRenderer.body(PageRenderer.java:85)
      org.springframework.extensions.surf.render.AbstractRenderer.render(AbstractRenderer.java:75)
      org.springframework.extensions.surf.render.RenderService.renderPage(RenderService.java:408)
      org.springframework.extensions.surf.mvc.PageView.dispatchPage(PageView.java:388)
      org.springframework.extensions.surf.mvc.PageView.renderView(PageView.java:329)
      org.springframework.extensions.surf.mvc.AbstractWebFrameworkView.renderMergedOutputModel(AbstractWebFrameworkView.java:285)
      org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
      org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1060)
      org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:798)
      org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
      org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647)
      org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:552)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      org.alfresco.web.site.servlet.MTAuthenticationFilter.doFilter(MTAuthenticationFilter.java:74)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      org.alfresco.web.site.servlet.SSOAuthenticationFilter.doFilter(SSOAuthenticationFilter.java:301)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
      org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
      org.apache.coyote.http11.Http11NioProcessor.process(Http11NioProcessor.java:883)
      org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:721)
      org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:2258)
      java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      java.lang.Thread.run(Thread.java:619)
      Exception: org.springframework.extensions.webscripts.WebScriptException – 05200000 Failed to process template org/alfresco/components/preview/web-preview.get.html.ftl
      org.springframework.extensions.webscripts.processor.FTLTemplateProcessor.process(FTLTemplateProcessor.java:175)

      Any thoughts?

      Thanks

  6. I’m getting the below error upon attempting to start alfresco back up:

    un 16, 2011 10:18:52 AM org.apache.catalina.core.StandardContext listenerStart
    SEVERE: Exception sending context initialized event to listener instance of class org.alfresco.web.app.ContextListener
    org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:alfresco/application-context.xml]
    Offending resource: ServletContext resource [/WEB-INF/web-application-context.xml]; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath*:alfresco/extension/*-context.xml]
    Offending resource: class path resource [alfresco/application-context.xml]; nested exception is org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 4 in XML document from file [C:\Alfresco34d\tomcat\webapps\alfresco\WEB-INF\classes\alfresco\extension\tiff-transform-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException: Invalid byte 1 of 1-byte UTF-8 sequence.
    at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
    at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
    at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:76)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:193)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseDefaultElement(DefaultBeanDefinitionDocumentReader.java:148)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:133)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:93)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
    at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124)
    at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:93)
    at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
    at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:458)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:388)
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:261)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:192)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
    at org.alfresco.web.app.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:63)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3972)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4467)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
    at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:637)
    at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:563)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:498)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    at org.apache.catalina.core.StandardService.start(StandardService.java:519)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
    Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath*:alfresco/extension/*-context.xml]
    Offending resource: class path resource [alfresco/application-context.xml]; nested exception is org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 4 in XML document from file [C:\Alfresco34d\tomcat\webapps\alfresco\WEB-INF\classes\alfresco\extension\tiff-transform-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException: Invalid byte 1 of 1-byte UTF-8 sequence.
    at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
    at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
    at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:76)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:193)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseDefaultElement(DefaultBeanDefinitionDocumentReader.java:148)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:133)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:93)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:187)
    … 43 more
    Caused by: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 4 in XML document from file [C:\Alfresco34d\tomcat\webapps\alfresco\WEB-INF\classes\alfresco\extension\tiff-transform-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException: Invalid byte 1 of 1-byte UTF-8 sequence.
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:187)
    … 53 more
    Caused by: org.xml.sax.SAXParseException: Invalid byte 1 of 1-byte UTF-8 sequence.
    at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
    at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
    at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)

    Any thoughts?

  7. Can you upload the files in their file formats so that I can download the file instead of copying out of your page with cntrl c?

    That would be awesome!

    Thanks

  8. Nevermind, I pasted into notepad and found the issue you were speaking of and removed all of these foreign characters.

    Now I am having the issue that I’ve followed the stepst hat you’ve provided ;however, when I attempt to view the image now.. it says no preview available.

    I am using alfresco 34d has this been tested with this build?

    I see no errors in the error log and nothing weird in the standard output log

  9. Okay I’ve gotten past these simple errors- I now am at the point where I’ve added the three files, changed the web-preview-min.js instead of the web-preview.js with the suggested changes but instead of what you have i just put into the -min.js file the logic: ‘if (this.options.mimeType.match(/^image\/tiff$/)) u = o; else’ However now when I go to view it, the previewer is loaded but then an error message pops up: “The preview could not be loaded from the server.” – Anythoughts? Thanks!!!

    • Fabio Strozzi

      Hi Mike, the *-min.js file are loaded by default unless you turn on a debug flag somewhere in the Share configuration xml. I’m sorry I didn’t mention it, I work in debug mode most of the time.
      Concerning the missing preview, don’t you have any logged errors?
      Try check the startup log of Alfresco and see if somewhere it is mentioned that Tiff2Swf and Tiff2Pdf components have been correctly loaded.
      Let me know

      Fabio

  10. nevermind i just replaced the whole viewer with one that doesn’t conver the image at all and can read multipage tiff-I wasn’t able to get your solution working- no errors were being thrown everywhere and everything seemed to load correctly.

    Thanks!

  11. Thank you Fabio for your post.
    @Mike – I am also interested in changing the view-er, can you give me some direction on this?

  12. I’ve been trying to implement this in my alfresco 3.4 with a very strange result. I am not an expert and maybe you will be able to spot the error. The strange result comes from adding the tiff-transform-context.xml file in the extension folder. It doesn’t matter if I use the shared folder or the web-app folder. It doesn’t even matter if the file has any text in it! The simple fact of adding the file to the folder creates havoc. I have not tested throughly, but once I add the file, I cannot log in anymore. After entering my user and pwd into the share login form, my credentials cannot be validated. When I delete the empty file, voila, everything works well again.
    Any ideas?? 😯

    • Fabio Strozzi

      Hi Rodolfo,
      I’ve recently ported this “hack” to Alfresco 3.4 community and with small changes it worked.
      I’ve no idea why it affected your login, I suppose it’s something related to Spring.
      Do you get any error in alfresco.log after you copy the file (even the empty one) and you restart Alfresco? Are you using a fresh installation of Alfresco or a customized one?
      Let me know

      Fabio

  13. HiFabio –

    Your article is very good. It helps me understand a little more about transformation integration in Alfresco.

    We’re trying to replace the default Flash previewer in Alfresco Share 3.4.x with a 3rd party document viewer such as Adeptol AJAXDocumentViewer (www.adeptol.com) to fulfill our digital rights management requirements, such that consumer users can only view the content, they cannot printing, saving or downloading the document.

    It’s much appreciated for any tips you can provide on replacing the default Flash preview in Alfresco Share.

    Thanks,
    TUan

    • Hi,
      thank you Tuan for your feedback, I’m glad you found my article useful.
      I think replacing the default viewer should not be much complicated if you adhere to the current paradigm:
      – from a backend prospective, you set up a transformation chain that generates content nodes in the format that has to be render (say swf if you’ll use Flash)
      – you customize Share to use a different viewer that renders a certain type of content (say swf).
      The last part is surely tougher but as I see that the tool you suggested (ww.adeptol.com) works very similar to the Alfresco viewer (it justs downloads swf resources), I’m sure it will turn out simpler than expected.
      My advice is to start by studying how Share/Surf works now, it’s a boring work but it’s not hard to understand.

      Let me know if you need help.

      Fabio

  14. Hello,

    I am trying to apply your fix to Alfresco 4.0a on Windows. The file locations are slightly different. I have used the following locations:

    C:\Alfresco\tomcat\webapps\alfresco\WEB-INF\classes\alfresco\subsystems\thirdparty\default

    tiff-transform-context.xml
    tiff-transform.properties

    C:\Alfresco\tomcat\webapps\alfresco\WEB-INF\classes\alfresco

    tiff-transform-context.xml

    I cannot locate the _resolvePreview function in $TOMCAT_HOME/webapps/share/components/preview.

    Therefore, I am at a standstill. The additional files haven’t broken anything, but (obviously) since I haven’t modified _resolvePreview, the additional files do nothing.

    Any help or suggestions would be greatly appreciated.

    Thanks!

    -Will

  15. Hi Will,
    sorry for not having replied you soon.
    Actually I’ve not yet tried version 4.0 and I guess much has changed since my last tests. So, don’t take for sure that the _resolvePreview function still exists.
    But, provided that a similar logic still holds, you should look for js files that contain keywords like webpreview, shockwave-flash and so on.
    Let me know if you don’t manage it.

    Thanks for posting

    Fabio

  16. Hi Fabio,

    So far I haven’t had any luck. Please let me know if/when you try version 4.0.

    Thanks!

    ~Will

  17. Any luck getting this to work on Alfresco 4?

  18. Thank you Fabio for this good article. It help us a lot to get rid of the Flash player in Alf3.4.

    FYI we transforming most of the file types into PDFs and then use a native browser PDF viewer/plugin (like Adobe Reader) to view them. We used the JS lib PDFObject for the markup.

    Kind regards,
    Jordi.

  19. I am not getting any luck with this solution. Alfresco 3.4 starts without error but as soon as I try to load the preview I get conversion errors in the log. Have you come across any gotchas during your development that I should try?

    • Fabio Strozzi

      Hi Pablo,
      sorry but I never tried with Alfresco 3.4.
      If you hit a specific error, you can paste it here.
      Best regards
      Fabio

      • Using version 4.0.d now. Log is below – any help would be great!!

        Wrapped Exception (with status template): 05030008 Failed to execute script ‘classpath*:alfresco/templates/webscripts/org/alfresco/repository/thumbnail/thumbnail.get.js’: 05030007 Content conversion failed:
        reader: ContentAccessor[ contentUrl=store://2012/6/3/21/16/7b20b4d1-190f-41e8-8f19-5f38004683b7.bin, mimetype=image/tiff, size=216392, encoding=UTF-8, locale=en_US]
        writer: ContentAccessor[ contentUrl=store://2012/6/3/21/27/0613f61a-6878-4705-94a1-0ea47e2c4167.bin, mimetype=application/x-shockwave-flash, size=0, encoding=UTF-8, locale=en_US]
        options: {targetContentProperty=null, contentReaderNodeRef=workspace://SpacesStore/c503d03d-1ed0-4804-a352-93a280f05c64, contentWriterNodeRef=workspace://SpacesStore/4aae45de-672a-4c84-9e87-77495016ae18, sourceContentProperty=null, includeEmbedded=false}
        limits: {timeoutMs=120000, maxPages=-1, readLimitKBytes=-1, maxSourceSizeKBytes=-1, pageLimit=-1, readLimitTimeMs=-1}
        org.springframework.extensions.webscripts.WebScriptException: 05030003 Wrapped Exception (with status template): 05030008 Failed to execute script ‘classpath*:alfresco/templates/webscripts/org/alfresco/repository/thumbnail/thumbnail.get.js’: 05030007 Content conversion failed:
        reader: ContentAccessor[ contentUrl=store://2012/6/3/21/16/7b20b4d1-190f-41e8-8f19-5f38004683b7.bin, mimetype=image/tiff, size=216392, encoding=UTF-8, locale=en_US]
        writer: ContentAccessor[ contentUrl=store://2012/6/3/21/27/0613f61a-6878-4705-94a1-0ea47e2c4167.bin, mimetype=application/x-shockwave-flash, size=0, encoding=UTF-8, locale=en_US]
        options: {targetContentProperty=null, contentReaderNodeRef=workspace://SpacesStore/c503d03d-1ed0-4804-a352-93a280f05c64, contentWriterNodeRef=workspace://SpacesStore/4aae45de-672a-4c84-9e87-77495016ae18, sourceContentProperty=null, includeEmbedded=false}
        limits: {timeoutMs=120000, maxPages=-1, readLimitKBytes=-1, maxSourceSizeKBytes=-1, pageLimit=-1, readLimitTimeMs=-1}
        at org.springframework.extensions.webscripts.AbstractWebScript.createStatusException(AbstractWebScript.java:970)
        at org.alfresco.repo.web.scripts.content.StreamContent.execute(StreamContent.java:211)
        at org.alfresco.repo.web.scripts.RepositoryContainer$2.execute(RepositoryContainer.java:400)
        at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:388)
        at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:462)
        at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:500)
        at org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:316)
        at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:372)
        at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:209)
        at org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:118)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.alfresco.repo.webdav.auth.BaseSSOAuthenticationFilter.doFilter(BaseSSOAuthenticationFilter.java:136)
        at sun.reflect.GeneratedMethodAccessor386.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.alfresco.repo.management.subsystems.ChainingSubsystemProxyFactory$1.invoke(ChainingSubsystemProxyFactory.java:103)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
        at $Proxy241.doFilter(Unknown Source)
        at org.alfresco.repo.web.filter.beans.BeanProxyFilter.doFilter(BeanProxyFilter.java:82)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.alfresco.web.app.servlet.WebScriptSSOAuthenticationFilter.doFilter(WebScriptSSOAuthenticationFilter.java:140)
        at sun.reflect.GeneratedMethodAccessor386.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.alfresco.repo.management.subsystems.ChainingSubsystemProxyFactory$1.invoke(ChainingSubsystemProxyFactory.java:103)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
        at $Proxy241.doFilter(Unknown Source)
        at org.alfresco.repo.web.filter.beans.BeanProxyFilter.doFilter(BeanProxyFilter.java:82)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:58)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:470)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
        at java.lang.Thread.run(Thread.java:662)
        Caused by: org.alfresco.scripts.ScriptException: 05030008 Failed to execute script ‘classpath*:alfresco/templates/webscripts/org/alfresco/repository/thumbnail/thumbnail.get.js’: 05030007 Content conversion failed:
        reader: ContentAccessor[ contentUrl=store://2012/6/3/21/16/7b20b4d1-190f-41e8-8f19-5f38004683b7.bin, mimetype=image/tiff, size=216392, encoding=UTF-8, locale=en_US]
        writer: ContentAccessor[ contentUrl=store://2012/6/3/21/27/0613f61a-6878-4705-94a1-0ea47e2c4167.bin, mimetype=application/x-shockwave-flash, size=0, encoding=UTF-8, locale=en_US]
        options: {targetContentProperty=null, contentReaderNodeRef=workspace://SpacesStore/c503d03d-1ed0-4804-a352-93a280f05c64, contentWriterNodeRef=workspace://SpacesStore/4aae45de-672a-4c84-9e87-77495016ae18, sourceContentProperty=null, includeEmbedded=false}
        limits: {timeoutMs=120000, maxPages=-1, readLimitKBytes=-1, maxSourceSizeKBytes=-1, pageLimit=-1, readLimitTimeMs=-1}
        at org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:195)
        at org.alfresco.repo.processor.ScriptServiceImpl.execute(ScriptServiceImpl.java:212)
        at org.alfresco.repo.processor.ScriptServiceImpl.executeScript(ScriptServiceImpl.java:174)
        at org.alfresco.repo.web.scripts.RepositoryScriptProcessor.executeScript(RepositoryScriptProcessor.java:102)
        at org.springframework.extensions.webscripts.AbstractWebScript.executeScript(AbstractWebScript.java:1193)
        at org.alfresco.repo.web.scripts.content.StreamContent.execute(StreamContent.java:155)
        … 47 more
        Caused by: org.alfresco.service.cmr.repository.ContentIOException: 05030007 Content conversion failed:
        reader: ContentAccessor[ contentUrl=store://2012/6/3/21/16/7b20b4d1-190f-41e8-8f19-5f38004683b7.bin, mimetype=image/tiff, size=216392, encoding=UTF-8, locale=en_US]
        writer: ContentAccessor[ contentUrl=store://2012/6/3/21/27/0613f61a-6878-4705-94a1-0ea47e2c4167.bin, mimetype=application/x-shockwave-flash, size=0, encoding=UTF-8, locale=en_US]
        options: {targetContentProperty=null, contentReaderNodeRef=workspace://SpacesStore/c503d03d-1ed0-4804-a352-93a280f05c64, contentWriterNodeRef=workspace://SpacesStore/4aae45de-672a-4c84-9e87-77495016ae18, sourceContentProperty=null, includeEmbedded=false}
        limits: {timeoutMs=120000, maxPages=-1, readLimitKBytes=-1, maxSourceSizeKBytes=-1, pageLimit=-1, readLimitTimeMs=-1}
        at org.alfresco.repo.content.transform.AbstractContentTransformer2.transform(AbstractContentTransformer2.java:188)
        at org.alfresco.repo.content.ContentServiceImpl.transform(ContentServiceImpl.java:589)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
        at net.sf.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:80)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.alfresco.repo.model.ml.MLContentInterceptor.invoke(MLContentInterceptor.java:125)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:46)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:147)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
        at $Proxy52.transform(Unknown Source)
        at org.alfresco.repo.rendition.executer.AbstractTransformationRenderingEngine.render(AbstractTransformationRenderingEngine.java:120)
        at org.alfresco.repo.rendition.executer.AbstractRenderingEngine.executeRenditionImpl(AbstractRenderingEngine.java:504)
        at org.alfresco.repo.rendition.executer.AbstractRenderingEngine$1.doWork(AbstractRenderingEngine.java:428)
        at org.alfresco.repo.rendition.executer.AbstractRenderingEngine$1.doWork(AbstractRenderingEngine.java:408)
        at org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(AuthenticationUtil.java:519)
        at org.alfresco.repo.rendition.executer.AbstractRenderingEngine.executeImpl(AbstractRenderingEngine.java:407)
        at org.alfresco.repo.rendition.executer.AbstractRenderingEngine.executeImpl(AbstractRenderingEngine.java:369)
        at org.alfresco.repo.action.executer.ActionExecuterAbstractBase.execute(ActionExecuterAbstractBase.java:196)
        at org.alfresco.repo.action.ActionServiceImpl.directActionExecution(ActionServiceImpl.java:780)
        at org.alfresco.repo.action.ActionServiceImpl.executeActionImpl(ActionServiceImpl.java:700)
        at org.alfresco.repo.action.ActionServiceImpl.executeAction(ActionServiceImpl.java:538)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
        at org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor.invoke(AlwaysProceedMethodInterceptor.java:34)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:46)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:147)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
        at $Proxy37.executeAction(Unknown Source)
        at org.alfresco.repo.rendition.RenditionServiceImpl.executeRenditionAction(RenditionServiceImpl.java:281)
        at org.alfresco.repo.rendition.RenditionServiceImpl.render(RenditionServiceImpl.java:183)
        at org.alfresco.repo.thumbnail.ThumbnailServiceImpl.createThumbnailNode(ThumbnailServiceImpl.java:588)
        at org.alfresco.repo.thumbnail.ThumbnailServiceImpl.access$000(ThumbnailServiceImpl.java:67)
        at org.alfresco.repo.thumbnail.ThumbnailServiceImpl$1.doWork(ThumbnailServiceImpl.java:262)
        at org.alfresco.repo.thumbnail.ThumbnailServiceImpl$1.doWork(ThumbnailServiceImpl.java:259)
        at org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(AuthenticationUtil.java:519)
        at org.alfresco.repo.thumbnail.ThumbnailServiceImpl.createThumbnail(ThumbnailServiceImpl.java:258)
        at org.alfresco.repo.thumbnail.ThumbnailServiceImpl.createThumbnail(ThumbnailServiceImpl.java:222)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
        at org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor.invoke(AlwaysProceedMethodInterceptor.java:34)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:46)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:147)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
        at $Proxy123.createThumbnail(Unknown Source)
        at org.alfresco.repo.jscript.ScriptNode.createThumbnail(ScriptNode.java:2747)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:155)
        at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:243)
        at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:76)
        at org.mozilla.javascript.gen.c13._c1(file:/opt/alfresco-4.0.d/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/repository/thumbnail/thumbnail.get.js:68)
        at org.mozilla.javascript.gen.c13.call(file:/opt/alfresco-4.0.d/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/repository/thumbnail/thumbnail.get.js)
        at org.mozilla.javascript.optimizer.OptRuntime.callName0(OptRuntime.java:108)
        at org.mozilla.javascript.gen.c13._c0(file:/opt/alfresco-4.0.d/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/repository/thumbnail/thumbnail.get.js:109)
        at org.mozilla.javascript.gen.c13.call(file:/opt/alfresco-4.0.d/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/repository/thumbnail/thumbnail.get.js)
        at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393)
        at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2834)
        at org.mozilla.javascript.gen.c13.call(file:/opt/alfresco-4.0.d/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/repository/thumbnail/thumbnail.get.js)
        at org.mozilla.javascript.gen.c13.exec(file:/opt/alfresco-4.0.d/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/repository/thumbnail/thumbnail.get.js)
        at org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:483)
        at org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:191)
        … 52 more
        Caused by: org.alfresco.service.cmr.repository.ContentIOException: 05030006 Content conversion failed:
        reader: ContentAccessor[ contentUrl=store://2012/6/3/21/16/7b20b4d1-190f-41e8-8f19-5f38004683b7.bin, mimetype=image/tiff, size=216392, encoding=UTF-8, locale=en_US]
        writer: ContentAccessor[ contentUrl=store:///opt/alfresco-4.0.d/tomcat/temp/Alfresco/ComplextTransformer_intermediate_tiff_5314510743190565724.pdf, mimetype=application/pdf, size=0, encoding=UTF-8, locale=en_US]
        options: {targetContentProperty=null, contentReaderNodeRef=workspace://SpacesStore/c503d03d-1ed0-4804-a352-93a280f05c64, contentWriterNodeRef=workspace://SpacesStore/4aae45de-672a-4c84-9e87-77495016ae18, sourceContentProperty=null, includeEmbedded=false}
        limits: {timeoutMs=120000, maxPages=-1, readLimitKBytes=-1, maxSourceSizeKBytes=-1, pageLimit=-1, readLimitTimeMs=-1}
        at org.alfresco.repo.content.transform.AbstractContentTransformer2.transform(AbstractContentTransformer2.java:188)
        at org.alfresco.repo.content.transform.ComplexContentTransformer.transformInternal(ComplexContentTransformer.java:255)
        at org.alfresco.repo.content.transform.AbstractContentTransformer2.transform(AbstractContentTransformer2.java:171)
        … 145 more
        Caused by: org.alfresco.service.cmr.repository.ContentIOException: 05030005 Transformation failed – status indicates an error:
        Execution result:
        os: Linux
        command: [/opt/alfresco-4.0.d/common/bin/convert, /opt/alfresco-4.0.d/tomcat/temp/Alfresco/RuntimeExecutableContentTransformerWorker_source_6351294437585724201.tiff, /opt/alfresco-4.0.d/tomcat/temp/Alfresco/RuntimeExecutableContentTransformerWorker_target_8405199589816724460.pdf]
        succeeded: false
        exit code: 1
        out:
        err: /tmp/magick-XXleBx2u: Failed to allocate memory for to read TIFF directory (0 elements of 12 bytes each).
        TIFFReadDirectory: /tmp/magick-XXleBx2u: Failed to read directory at offset 0.
        /tmp/magick-XXx4ZiDS: Failed to allocate memory for to read TIFF
        at org.alfresco.repo.content.transform.RuntimeExecutableContentTransformerWorker.transform(RuntimeExecutableContentTransformerWorker.java:273)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.alfresco.repo.management.subsystems.SubsystemProxyFactory$1.invoke(SubsystemProxyFactory.java:65)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
        at $Proxy11.transform(Unknown Source)
        at org.alfresco.repo.content.transform.ProxyContentTransformer.transformInternal(ProxyContentTransformer.java:76)
        at org.alfresco.repo.content.transform.AbstractContentTransformer2.transform(AbstractContentTransformer2.java:171)
        … 147 more

        • Fabio Strozzi

          Hi Pablo, sounds like something went wrong during the conversion with the convert tool:

          Caused by: org.alfresco.service.cmr.repository.ContentIOException: 05030005 Transformation failed – status indicates an error:
          Execution result:
          os: Linux
          command: [/opt/alfresco-4.0.d/common/bin/convert, /opt/alfresco-4.0.d/tomcat/temp/Alfresco/RuntimeExecutableContentTransformerWorker_source_6351294437585724201.tiff, /opt/alfresco-4.0.d/tomcat/temp/Alfresco/RuntimeExecutableContentTransformerWorker_target_8405199589816724460.pdf]
          succeeded: false
          exit code: 1
          out:
          err: /tmp/magick-XXleBx2u: Failed to allocate memory for to read TIFF directory (0 elements of 12 bytes each).
          TIFFReadDirectory: /tmp/magick-XXleBx2u: Failed to read directory at offset 0.
          /tmp/magick-XXx4ZiDS: Failed to allocate memory for to read TIFF

          Does the convert command that is shipped with Alfresco work? Can you manually convert a tiff file to pdf in a terminal?

          Fabio

  20. Andreas Keller

    I used alfresco CE 4.02 with an OCR tiff2pdf transformer. abbyyocr does an excellent job under debian Linux.

    Alfresco CE 4.2 is using Immagemagick tiff2pdf as default transformer because it’s faster than the ocr transformer.

    I tried different solutions (p.e. transformer limits) without success. Is there an easy way to configure immagemagick in such a way that it not transforms tiff to pdf any more?

    Andreas

  21. Great Article!
    I had a problem with an xls document A showing preview of another xls document B, which I think is being caused by caching. This article guided me in the right direction by explaining each step. Now its a lot easier to debug the issue.

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>