cancel
Showing results for 
Search instead for 
Did you mean: 

BeanCreation Exception: RuntimeExecutableContentTransformer

jsauer
Champ in-the-making
Champ in-the-making
Hi,
just want to register a simple RuntimeExecutableContentTransformerWorker based transformer. Does not work whatever I do. After lots of research here, the Wiki and other places no success so far.

Environment: Alfresco 3.2.r2 on Windows XP SP3

As my code did not work, I tried the code from the wiki.

classpath:alfresco/extension/my-runtime-exec-transformers-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.Tidy.XHTML" class="org.alfresco.repo.content.transform.RuntimeExecutableContentTransformerWorker" parent="baseContentTransformer">
      <property name="mimetypeService">
         <ref bean="mimetypeService" />
      </property>
      <property name="checkCommand">
         <bean class="org.alfresco.util.exec.RuntimeExec">
            <property name="commandMap">
                <map>
                    <entry key=".*">
                        <value>tidy -help</value>
                    </entry>
                </map>
            </property>
            <property name="errorCodes">
               <value>2</value>
            </property>
         </bean>
      </property>
      <property name="transformCommand">
         <bean class="org.alfresco.util.exec.RuntimeExec">
            <property name="commandMap">
                <map>
                    <entry key="Linux">
                        <value>tidy -asxhtml -o '${target}' '${source}'</value>
                    </entry>
                    <entry key="Windows.*">
                        <value>tidy -asxhtml -o "${target}" "${source}"</value>
                    </entry>
                </map>
            </property>
            <property name="errorCodes">
               <value>2</value>
            </property>
         </bean>
      </property>
      <property name="explicitTransformations">
         <list>
            <bean class="org.alfresco.repo.content.transform.ExplictTransformationDetails" >
                <property name="sourceMimetype"><value>text/html</value></property>
                <property name="targetMimetype"><value>application/xhtml+xml</value></property>
            </bean>
         </list>
      </property>
   </bean>
</beans>

Error Message:

21:35:14,546 ERROR [org.springframework.web.context.ContextLoader] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transformer.Tidy.XHTML' defined in file [D:\Alfresco\tomcat\webapps\alfresco\WEB-INF\classes\alfresco\extension\my-runtime-exec-transformers-context.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'registry' of bean class [org.alfresco.repo.content.transform.RuntimeExecutableContentTransformerWorker]: Bean property 'registry' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'registry' of bean class [org.alfresco.repo.content.transform.RuntimeExecutableContentTransformerWorker]: Bean property 'registry' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
   at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:793)
   at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:645)
   at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:78)
   at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:59)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1127)


The code in the wiki does not use:

      <property name="mimetypeService">
         <ref bean="mimetypeService" />
      </property>
I looked it up at imagemagick-transform-context.xml as I thought it might be missing as some 'registry' seems to be the problem.

Any ideas?

Thanks
Jörg
PS: why will the bean never be processed if I place it under a subdirectory of extension, e.g. classpath:alfresco/extension/mytransformers/my-runtime-exec-transformers-context.xml ?
7 REPLIES 7

mycroes
Champ in-the-making
Champ in-the-making
I'm seeing the same issue. I've also looked at the ImageMagick transformer, noticed that they named all the beans. Tried that, didn't help. I also noticed that the ImageMagick transformer doesn't use the same property names as are used on the wiki. I don't know if those names are free to choose, but I would assume they're not. So currently I'm stuck in the same situation, not able to add my simple command line transformer.
Regards,

Michael

mrogers
Star Contributor
Star Contributor
The problem is that there's no "registry" property.  

You need to fulfill this bit of the config.
 

<bean id="baseContentTransformer"
         class="org.alfresco.repo.content.transform.AbstractContentTransformer"
         abstract="true"
         init-method="register">
      <property name="mimetypeService">
         <ref bean="mimetypeService" />
      </property>
      <property name="registry">
         <ref bean="contentTransformerRegistry" />
      </property>
   </bean>

mycroes
Champ in-the-making
Champ in-the-making
The problem is that there's no "registry" property.

Personally, I think the problem is in bad documentation. The wiki fails to give correct and complete information, luckily I was able to figure out the solution myself (before I actually read your solution):

<?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.dwg2pdf" 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="commandsAndArguments">
                    <map>
                        <entry key=".*">
                            <list>
                                <value>ls</value>
                                <value>/usr/local/bin/dwg2pdf</value>
                            </list>
                        </entry>
                    </map>
                </property>
                <property name="errorCodes">
                    <value>2</value>
                </property>
            </bean>
        </property>

        <property name="transformCommand">
            <bean class="org.alfresco.util.exec.RuntimeExec">
                <property name="commandsAndArguments">
                    <map>
                        <entry key=".*">
                            <list>
                                <value>/usr/local/bin/dwg2pdf</value>
                                <value>${source}</value>
                                <value>${target}</value>
                            </list>
                        </entry>
                    </map>
                </property>
                <property name="errorCodes">
                    <value>1,2</value>
                </property>
            </bean>
        </property>

        <property name="explicitTransformations">
            <list>
                <bean class="org.alfresco.repo.content.transform.ExplictTransformationDetails">
                    <property name="sourceMimetype"><value>image/x-dwg</value></property>
                    <property name="targetMimetype"><value>application/pdf</value></property>
                </bean>
            </list>
        </property>
    </bean>

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

What was missing was the fact that due to the worker transformation there needed to be another bean referring to the worker. Although this is explained somewhat in upgrading-to-3.2 page on the wiki, the page about content transformations lacked a proper explanation. Also, I didn't upgrade from anything, so I wouldn't expect the need to look at the upgrading page for a fresh install.

I also noticed that when the mimetypeService property is missing, a null pointer exception is thrown. Even when logging for content transformations is set to debug it's not clear where this comes from, but just adding the property solved it for me.

Last I noticed that the commandMap property was deprecated, and should be replaced by commandsAndArguments, so I did that for my transformer. Also, I currently rely on being able to find the executable as a test to whether it works, which is fine for me but of course should not be used for most people (the executable is an in-company developed converter, which currently lacks a help option or similar so I can't do a proper check right now).

However, could you explain the difference between my solution and yours. It seems to me that your solution is redefining the baseContentTransformer in some way, which doesn't seem like an ideal solution to me…
Regards,

Michael

mycroes
Champ in-the-making
Champ in-the-making
Meanwhile I updated the wiki to at least add my file as example, would be nice if you would also be able to read and verify that as to make sure it's useful for other users.
Regards,

Michael

dirk1
Champ in-the-making
Champ in-the-making
Hello Michael,

Meanwhile I updated the wiki to at least add my file as example,

Could you please give us a link to that wiki?

Thanks a lot.

Dirk

dirk1
Champ in-the-making
Champ in-the-making
Hello mrogers,

The problem is that there's no "registry" property.

You need to fulfill this bit of the config.

Your posted code is identical to that what i found in my content-services-context.xml.
Nevertheless it happens the above posted error.

Any more ideas?

Thanks

Dirk

mycroes
Champ in-the-making
Champ in-the-making
Meanwhile I updated the wiki to at least add my file as example,

Could you please give us a link to that wiki?

Sorry I wasn't watching the topic, here it is:
http://wiki.alfresco.com/wiki/Content_Transformations

I also added a page describing our complete DWG transformation setup with additional information, you can find that here (also includes the example):
http://wiki.alfresco.com/wiki/DWG_Transformations
Regards,

Michael