cancel
Showing results for 
Search instead for 
Did you mean: 

Error enabling custom metadata extraction

kbonnet
Champ in-the-making
Champ in-the-making
Hi Alfrescians,

I'm trying to enable a custom metadata extraction to retrieve properties from Word documents. I tried to the following bean definition in my extension root:


  <bean id="extracter.TikaAuto" class="org.alfresco.repo.content.metadata.TikaAutoMetadataExtracter" parent="baseMetadataExtracter">
        <property name="inheritDefaultMapping">
            <value>true</value>
        </property>
        <property name="mappingProperties">
            <props>
                <prop key="namespace.prefix.cm">http://www.alfresco.org/model/content/1.0</prop>
                <prop key="afdeling">cm:description</prop>
            </props>
        </property>
    </bean>

However, I get the following error:


2012-03-08 10:04:23,081  ERROR [web.context.ContextLoader] [Thread-1] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'extracter.TikaAuto' defined in file [C:\Alfresco\tomcat\shared\classes\alfresco\extension\custom-metadata-extrators-context.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.alfresco.repo.content.metadata.TikaAutoMetadataExtracter]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.alfresco.repo.content.metadata.TikaAutoMetadataExtracter.<init>()
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:965)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:911)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
   at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
   at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
   at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
   at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
   at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
   at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
   at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
   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:4135)
   at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)
   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:445)
   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.BeanInstantiationException: Could not instantiate bean class [org.alfresco.repo.content.metadata.TikaAutoMetadataExtracter]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.alfresco.repo.content.metadata.TikaAutoMetadataExtracter.<init>()
   at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:70)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:958)
   … 38 more
Caused by: java.lang.NoSuchMethodException: org.alfresco.repo.content.metadata.TikaAutoMetadataExtracter.<init>()
   at java.lang.Class.getConstructor0(Class.java:2706)
   at java.lang.Class.getDeclaredConstructor(Class.java:1985)
   at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:65)
   … 39 more


I'm using Alfresco Community 4.0 on Tomcat on Windows and with MySQL.

Has anything changed here?

Thanks for any help or clues.

Koen
8 REPLIES 8

amandaluniz_z
Champ on-the-rise
Champ on-the-rise
The TikaAutoMetadataExtracter has no default constructor, thus when instantiating it you'll need to pass the TikaConfig argument to the constructor using the constructor-arg tag

kbonnet
Champ in-the-making
Champ in-the-making
Thanks Amandaluniz,

At least the bean override is accepted and Alfresco is starting again. But my newly added word-property is ignored. Should this tikaConfig contain the mapping of word-properties to Alfresco properties? I was reusing a sample override, but it seems to be working no longer.

Thanks for your help so far.

Koen

amandaluniz_z
Champ on-the-rise
Champ on-the-rise
Hi kbonnet,

Are you saying you extended the TikaAutoMetadataExtracter by adding a word-properties getter and setter?

Could you repost your xml in case it's different to the one you posted?

Adei

kbonnet
Champ in-the-making
Champ in-the-making
No, i just wanted to add extra word-properties to get from documents and save to Alfresco documents. This is per the sample configuration, but something seems to have changed.

The original sample configuration from custom-metadata-extractors-context.xml is

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<!–
       This sample show how to modify the mappings properties of the new V2.1 Metadata Extractors.
       In this example, in addition to the default mappings, the field 'user1' is mapped to
       'cm:description'.  The available source properties is described on the Javadocs of the
       extracter class.
–>
<beans>

    <!– This adds in the extra mapping for the Open Document extractor –>
    <bean id="extracter.OpenDocument" class="org.alfresco.repo.content.metadata.OpenDocumentMetadataExtracter" parent="baseMetadataExtracter" >
        <property name="inheritDefaultMapping">
            <value>true</value>
        </property>
        <property name="mappingProperties">
            <props>
                <prop key="namespace.prefix.cm">http://www.alfresco.org/model/content/1.0</prop>
                <prop key="user1">cm:description</prop>
            </props>
        </property>
    </bean>

    <!– While this one adds it for the Tika Auto-Detect extractor –>
   <bean id="extracter.TikaAuto" class="org.alfresco.repo.content.metadata.TikaAutoMetadataExtracter" parent="baseMetadataExtracter">
        <property name="inheritDefaultMapping">
            <value>true</value>
        </property>
        <property name="mappingProperties">
            <props>
                <prop key="namespace.prefix.cm">http://www.alfresco.org/model/content/1.0</prop>
                <prop key="user1">cm:description</prop>
            </props>
        </property>
    </bean>
</beans>



My current config is:

<?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="extracter.OpenDocument" class="org.alfresco.repo.content.metadata.OpenDocumentMetadataExtracter" parent="baseMetadataExtracter">
        <property name="inheritDefaultMapping">
            <value>true</value>
        </property>
        <property name="mappingProperties">
            <props>
                <prop key="namespace.prefix.cm">http://www.alfresco.org/model/content/1.0</prop>
                <prop key="afdeling">cm:description</prop>
            </props>
        </property>
    </bean>



   <bean id="extracter.TikaAuto" class="org.alfresco.repo.content.metadata.TikaAutoMetadataExtracter" parent="baseMetadataExtracter">
   <constructor-arg><ref bean="tikaConfig"/></constructor-arg>
        <property name="inheritDefaultMapping">
            <value>true</value>
        </property>
        <property name="mappingProperties">
            <props>
                <prop key="namespace.prefix.cm">http://www.alfresco.org/model/content/1.0</prop>
                <prop key="afdeling">cm:description</prop>
            </props>
        </property>
    </bean>


</beans>


The bean for OpenOffice documents is working. For Tika it isnt.

Thanks a lot for your help.

Koen

kbonnet
Champ in-the-making
Champ in-the-making
No, i just wanted to add extra word-properties to get from documents and save to Alfresco documents

To avoid miscommunication, my reply should have read


"No, i just wanted to add extra word-properties to get from documents and save to Alfresco properties"

Smiley Happy

kbonnet
Champ in-the-making
Champ in-the-making
Because at least the sample configuration needs a change on this point, i created an issue:

https://issues.alfresco.com/jira/browse/ALF-13280.

Further help still appreciated. Smiley Happy

giorgio_draghet
Champ in-the-making
Champ in-the-making
I need to do the same thing that kbonnet described in this post: extract "custom" metadata from Word files (and/or PDF) and save into the Alfresco properties.
Both OpenDocument and TikaAuto seem to ignore the configuration.

Steps taken in a fresh install (Alfresco 5.0 and Alfresco 4.2):
1 -  enabled the sample file tomcat/shared/classes/alfresco/extension/custom-metadata-extrators-context.xml
As reported above, this sample file is configured to extract the metadata "user1" and save that value in the "cm:description" property
2 - the metadata "user1" was added into a word file
3 - the word file was uploaded to the repository
I expected to find the user1 value into the property "Description" but did not happen.
The are not errors in the log.

Is there anything that I did not understand or had to do and I did not?

Thanks in advance

lplp
Champ in-the-making
Champ in-the-making
I guess we did quite the same and it worked…
Except that we put the mapping in a .properties file as explained here : http://dev.alfresco.com/resource/docs/java/org/alfresco/repo/content/metadata/AbstractMappingMetadat...

Btw, you should enable debug mode on org.alfresco.repo.content.metadata so you can check if the problem is your custom property not been read out of the document or not written inside of cm:description.

Regards
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.