AnsweredAssumed Answered

scheduled copy action throws nullpointerexception

Question asked by mrksjs on Sep 25, 2012
Latest reply on Sep 26, 2012 by mrksjs
hi

i edited the file scheduled-action-services-context.xml like this:

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

<beans>
   
    <!–
    Define the model factory used to generate object models suitable for use with freemarker templates.
    –>
    <bean id="templateActionModelFactory" class="org.alfresco.repo.action.scheduled.FreeMarkerWithLuceneExtensionsModelFactory">
        <property name="serviceRegistry">
            <ref bean="ServiceRegistry"/>
        </property>
    </bean>

    <!–
    An example that copies the tutorial node into the company home space
    –>
    <bean id="copyAction" class="org.alfresco.repo.action.scheduled.SimpleTemplateActionDefinition">

        <property name="actionName">
            <value>copy</value>
        </property>

        <property name="parameterTemplates">
            <map>
                <entry>
                    <key>
                        <value>destination-folder</value>
                    </key>
                    <!– Note - FreeMarker ${..} entries must be escaped in Spring context files –>
                    <!– <value>\$\{selectSingleNode('workspace://SpacesStore', 'lucene', 'PATH:"/app:company_home/st:sites/cm:xml-import/cm:documentLibrary/cm:DocuGateImport/cm:AddAspect"' )\}</value> –>
               <value>\$\{selectSingleNode('workspace://SpacesStore', 'lucene', 'PATH:"/app:company_home"' )\}</value>
                </entry>
                <entry>
                    <key>
                        <value>assoc-type</value>
                    </key>
                    <!– Note - FreeMarker ${..} entries must be escaped in Spring context files –>
                    <value>\$\{node.primaryParentAssoc.typeQName\}</value>
                </entry>
                <entry>
                    <key>
                        <value>assoc-name</value>
                    </key>
                    <!– Note - FreeMarker ${..} entries must be escaped in Spring context files –>
                    <value>\$\{node.primaryParentAssoc.QName\}</value>
                </entry>
                <entry>
                    <key>
                        <value>deep-copy</value>
                    </key>
                    <value>false</value>
                </entry>
            </map>
        </property>
        <property name="templateActionModelFactory">
            <ref bean="templateActionModelFactory"/>
        </property>
        <property name="dictionaryService">
            <ref bean="DictionaryService"/>
        </property>
        <property name="actionService">
            <ref bean="ActionService"/>
        </property>
        <property name="templateService">
            <ref bean="TemplateService"/>
        </property>
    </bean>
   
    <!– ONE_TRANSACTION    ISOLATED_TRANSACTIONS      UNTIL_FIRST_FAILURE –>

    <bean id="copyTutorialEveryTenMinutes" class="org.alfresco.repo.action.scheduled.CronScheduledQueryBasedTemplateActionDefinition">
        <property name="transactionMode">
            <value>UNTIL_FIRST_FAILURE</value>
        </property>
        <property name="compensatingActionMode">
            <value>IGNORE</value>
        </property>
        <property name="searchService">
            <ref bean="SearchService"/>
        </property>
        <property name="templateService">
            <ref bean="TemplateService"/>
        </property>
        <property name="queryLanguage">
            <value>lucene</value>
        </property>
        <property name="stores">
            <list>
                <value>workspace://SpacesStore</value>
            </list>
        </property>
        <property name="queryTemplate">
            <value>+PATH:"/app:company_home/st:sites/cm:xml-import/cm:documentLibrary/cm:DocuGateImport/cm:AddADocument/*"</value>
        </property>
        <property name="cronExpression">
            <value>59 * * * * ?</value>
        </property>
        <property name="jobName">
            <value>jobC</value>
        </property>
        <property name="jobGroup">
            <value>jobGroup</value>
        </property>
        <property name="triggerName">
            <value>triggerC</value>
        </property>
        <property name="triggerGroup">
            <value>triggerGroup</value>
        </property>
        <property name="scheduler">
            <ref bean="schedulerFactory"/>
        </property>
        <property name="actionService">
            <ref bean="ActionService"/>
        </property>
        <property name="templateActionModelFactory">
            <ref bean="templateActionModelFactory"/>
        </property>
        <property name="templateActionDefinition">
            <ref bean="copyAction"/>
        </property>
        <property name="transactionService">
            <ref bean="TransactionService"/>
        </property>
        <property name="runAsUser">
            <value>System</value>
        </property>
    </bean>
   
</beans>

it contains the values from the .sample file. however, if the action is run, it gives me a nullpointer exception:

 2012-09-25 17:50:59,047  ERROR [quartz.core.JobRunShell] [DefaultScheduler_Worker-9] Job jobGroup.jobC threw an unhandled Exception:
java.lang.NullPointerException
        at org.alfresco.repo.action.scheduled.SimpleTemplateActionDefinition.getAction(SimpleTemplateActionDefinition.java:212)
        at org.alfresco.repo.action.scheduled.CronScheduledQueryBasedTemplateActionDefinition.getAction(CronScheduledQueryBasedTemplateActionDefinition.java:262)
        at org.alfresco.repo.action.scheduled.AbstractScheduledAction$JobDefinition$1$2.execute(AbstractScheduledAction.java:563)
        at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:388)
        at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:259)
        at org.alfresco.repo.action.scheduled.AbstractScheduledAction$JobDefinition$1.runTransactionalAction(AbstractScheduledAction.java:557)
        at org.alfresco.repo.action.scheduled.AbstractScheduledAction$JobDefinition$1.doWork(AbstractScheduledAction.java:426)
        at org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(AuthenticationUtil.java:516)
        at org.alfresco.repo.action.scheduled.AbstractScheduledAction$JobDefinition.execute(AbstractScheduledAction.java:392)
        at org.quartz.core.JobRunShell.run(JobRunShell.java:216)
        at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:563)
2012-09-25 17:50:59,047  ERROR [quartz.core.ErrorLogger] [DefaultScheduler_Worker-9] Job (jobGroup.jobC threw an exception.
org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: java.lang.NullPointerException]
        at org.quartz.core.JobRunShell.run(JobRunShell.java:227)
        at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:563)
Caused by: java.lang.NullPointerException
        at org.alfresco.repo.action.scheduled.SimpleTemplateActionDefinition.getAction(SimpleTemplateActionDefinition.java:212)
        at org.alfresco.repo.action.scheduled.CronScheduledQueryBasedTemplateActionDefinition.getAction(CronScheduledQueryBasedTemplateActionDefinition.java:262)
        at org.alfresco.repo.action.scheduled.AbstractScheduledAction$JobDefinition$1$2.execute(AbstractScheduledAction.java:563)
        at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:388)
        at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:259)
        at org.alfresco.repo.action.scheduled.AbstractScheduledAction$JobDefinition$1.runTransactionalAction(AbstractScheduledAction.java:557)
        at org.alfresco.repo.action.scheduled.AbstractScheduledAction$JobDefinition$1.doWork(AbstractScheduledAction.java:426)
        at org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(AuthenticationUtil.java:516)
        at org.alfresco.repo.action.scheduled.AbstractScheduledAction$JobDefinition.execute(AbstractScheduledAction.java:392)
        at org.quartz.core.JobRunShell.run(JobRunShell.java:216)
        … 1 more


what im trying to do is

copy all files inside (changed the value for testing):
/app:company_home/st:sites/cm:xml-import/cm:documentLibrary/cm:DocuGateImport/cm:AddADocument/

to

/app:company_home/st:sites/cm:xml-import/cm:documentLibrary/cm:DocuGateImport/cm:AddAspect


every minute.

pretty simple. but i guess im making a mistake here.

Outcomes