AnsweredAssumed Answered

rule executed in abckground does not work

Question asked by gandrez on May 7, 2007
Latest reply on Oct 1, 2007 by tpasturel
Hi all!

There seems to be a problem with executing rules in background. In my use case I'm copying several documents in a transaction to a space and an inbound rule in that space which is adding custom aspects to all copies. But when the rule is executed, aspects are added to some documents, but not in all…when I set the rule not to execute in background everything works fine.
A similar situation happens from time to time when I transform a file in my workflow to a pdf file. Usually it works fine, but sometimes, the transformation doesn't happen, and my task disappears from the workflow (I waited long enough for the transformation to execute). Again, not executing the rule in background does the trick. Any ideas why?

And another question…

I'm using custom aspect similar to ContentHits that is updating a document every time the document is viewed. After a certain time Alfresco keeps throwing the following exception…

[12:54:34,125 ERROR [quartz.core.JobRunShell] Job DEFAULT.ftsIndexerJobDetail thr
ew an unhandled Exception:
org.alfresco.error.AlfrescoRuntimeException: Failed to execute transaction-level
behaviour public abstract void org.alfresco.repo.node.NodeServicePolicies$OnUpd
ateNodePolicy.onUpdateNode(org.alfresco.service.cmr.repository.NodeRef) in trans
action 54e16c46-fc89-11db-8b22-716575b48360
        at org.alfresco.repo.policy.TransactionBehaviourQueue.execute(Transactio
nBehaviourQueue.java:201)
        at org.alfresco.repo.policy.TransactionBehaviourQueue.beforeCommit(Trans
actionBehaviourQueue.java:133)
        at org.alfresco.repo.transaction.AlfrescoTransactionSupport$TransactionS
ynchronizationImpl.beforeCommit(AlfrescoTransactionSupport.java:591)
        at org.springframework.transaction.support.AbstractPlatformTransactionMa
nager.triggerBeforeCommit(AbstractPlatformTransactionManager.java:657)
        at org.springframework.transaction.support.AbstractPlatformTransactionMa
nager.processCommit(AbstractPlatformTransactionManager.java:482)
        at org.springframework.transaction.support.AbstractPlatformTransactionMa
nager.commit(AbstractPlatformTransactionManager.java:469)
        at org.springframework.transaction.interceptor.TransactionAspectSupport.
doCommitTransactionAfterReturning(TransactionAspectSupport.java:266)
        at org.springframework.transaction.interceptor.TransactionInterceptor.in
voke(TransactionInterceptor.java:106)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
ReflectiveMethodInvocation.java:170)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynami
cAopProxy.java:176)
        at $Proxy5.index(Unknown Source)
        at org.alfresco.repo.search.impl.lucene.fts.FTSIndexerJob.execute(FTSInd
exerJob.java:44)
        at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
        at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.j
ava:529)
Caused by: org.alfresco.repo.search.IndexerException: Can not mix FTS and transa
ctional updates
        at org.alfresco.repo.search.impl.lucene.LuceneIndexerImpl2.checkAbleToDo
Work(LuceneIndexerImpl2.java:240)
        at org.alfresco.repo.search.impl.lucene.LuceneIndexerImpl2.updateNode(Lu
ceneIndexerImpl2.java:375)
        at org.alfresco.repo.search.IndexerComponent.updateNode(IndexerComponent
.java:60)
        at org.alfresco.repo.node.index.NodeIndexer.onUpdateNode(NodeIndexer.jav
a:104)
        at sun.reflect.GeneratedMethodAccessor355.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.alfresco.repo.policy.JavaBehaviour$JavaMethodInvocationHandler.in
voke(JavaBehaviour.java:179)
        at $Proxy49.onUpdateNode(Unknown Source)
        at sun.reflect.GeneratedMethodAccessor296.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.alfresco.repo.policy.PolicyFactory$MultiHandler.invoke(PolicyFact
ory.java:251)
        at org.alfresco.repo.policy.$Proxy82.onUpdateNode(Unknown Source)
        at org.alfresco.repo.node.AbstractNodeServiceImpl.invokeOnUpdateNode(Abs
tractNodeServiceImpl.java:289)
        at org.alfresco.repo.node.db.DbNodeServiceImpl.setProperty(DbNodeService
Impl.java:1005)
        at sun.reflect.GeneratedMethodAccessor353.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.alfresco.repo.service.StoreRedirectorProxyFactory$RedirectorInvoc
ationHandler.invoke(StoreRedirectorProxyFactory.java:221)
        at $Proxy2.setProperty(Unknown Source)
        at org.alfresco.repo.node.MLPropertyInterceptor.invoke(MLPropertyInterce
ptor.java:222)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
ReflectiveMethodInvocation.java:170)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynami
cAopProxy.java:176)
        at $Proxy3.setProperty(Unknown Source)
        at org.alfresco.repo.audit.AuditableAspect$SetAuditProperties.doWork(Aud
itableAspect.java:264)
        at org.alfresco.repo.audit.AuditableAspect$SetAuditProperties.doWork(Aud
itableAspect.java:237)
        at org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(Au
thenticationUtil.java:252)
        at org.alfresco.repo.audit.AuditableAspect.onUpdateAudit(AuditableAspect
.java:190)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.alfresco.repo.policy.JavaBehaviour$JavaMethodInvocationHandler.in
voke(JavaBehaviour.java:179)
        at $Proxy49.onUpdateNode(Unknown Source)
        at sun.reflect.GeneratedMethodAccessor296.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.alfresco.repo.policy.TransactionBehaviourQueue.execute(Transactio
nBehaviourQueue.java:189)
        … 13 more
12:54:34,234 ERROR [quartz.core.ErrorLogger] Job (DEFAULT.ftsIndexerJobDetail th
rew an exception.
org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exc
eption: org.alfresco.error.AlfrescoRuntimeException: Failed to execute transacti
on-level behaviour public abstract void org.alfresco.repo.node.NodeServicePolici
es$OnUpdateNodePolicy.onUpdateNode(org.alfresco.service.cmr.repository.NodeRef)
in transaction 54e16c46-fc89-11db-8b22-716575b48360]
        at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
        at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.j
ava:529)
Caused by: org.alfresco.error.AlfrescoRuntimeException: Failed to execute transa
ction-level behaviour public abstract void org.alfresco.repo.node.NodeServicePol
icies$OnUpdateNodePolicy.onUpdateNode(org.alfresco.service.cmr.repository.NodeRe
f) in transaction 54e16c46-fc89-11db-8b22-716575b48360
        at org.alfresco.repo.policy.TransactionBehaviourQueue.execute(Transactio
nBehaviourQueue.java:201)
        at org.alfresco.repo.policy.TransactionBehaviourQueue.beforeCommit(Trans
actionBehaviourQueue.java:133)
        at org.alfresco.repo.transaction.AlfrescoTransactionSupport$TransactionS
ynchronizationImpl.beforeCommit(AlfrescoTransactionSupport.java:591)
        at org.springframework.transaction.support.AbstractPlatformTransactionMa
nager.triggerBeforeCommit(AbstractPlatformTransactionManager.java:657)
        at org.springframework.transaction.support.AbstractPlatformTransactionMa
nager.processCommit(AbstractPlatformTransactionManager.java:482)
        at org.springframework.transaction.support.AbstractPlatformTransactionMa
nager.commit(AbstractPlatformTransactionManager.java:469)
        at org.springframework.transaction.interceptor.TransactionAspectSupport.
doCommitTransactionAfterReturning(TransactionAspectSupport.java:266)
        at org.springframework.transaction.interceptor.TransactionInterceptor.in
voke(TransactionInterceptor.java:106)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
ReflectiveMethodInvocation.java:170)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynami
cAopProxy.java:176)
        at $Proxy5.index(Unknown Source)
        at org.alfresco.repo.search.impl.lucene.fts.FTSIndexerJob.execute(FTSInd
exerJob.java:44)
        at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
        … 1 more
Caused by: org.alfresco.repo.search.IndexerException: Can not mix FTS and transa
ctional updates
        at org.alfresco.repo.search.impl.lucene.LuceneIndexerImpl2.checkAbleToDo
Work(LuceneIndexerImpl2.java:240)
        at org.alfresco.repo.search.impl.lucene.LuceneIndexerImpl2.updateNode(Lu
ceneIndexerImpl2.java:375)
        at org.alfresco.repo.search.IndexerComponent.updateNode(IndexerComponent
.java:60)
        at org.alfresco.repo.node.index.NodeIndexer.onUpdateNode(NodeIndexer.jav
a:104)
        at sun.reflect.GeneratedMethodAccessor355.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.alfresco.repo.policy.JavaBehaviour$JavaMethodInvocationHandler.in
voke(JavaBehaviour.java:179)
        at $Proxy49.onUpdateNode(Unknown Source)
        at sun.reflect.GeneratedMethodAccessor296.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.alfresco.repo.policy.PolicyFactory$MultiHandler.invoke(PolicyFact
ory.java:251)
        at org.alfresco.repo.policy.$Proxy82.onUpdateNode(Unknown Source)
        at org.alfresco.repo.node.AbstractNodeServiceImpl.invokeOnUpdateNode(Abs
tractNodeServiceImpl.java:289)
        at org.alfresco.repo.node.db.DbNodeServiceImpl.setProperty(DbNodeService
Impl.java:1005)
        at sun.reflect.GeneratedMethodAccessor353.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.alfresco.repo.service.StoreRedirectorProxyFactory$RedirectorInvoc
ationHandler.invoke(StoreRedirectorProxyFactory.java:221)
        at $Proxy2.setProperty(Unknown Source)
        at org.alfresco.repo.node.MLPropertyInterceptor.invoke(MLPropertyInterce
ptor.java:222)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
ReflectiveMethodInvocation.java:170)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynami
cAopProxy.java:176)
        at $Proxy3.setProperty(Unknown Source)
        at org.alfresco.repo.audit.AuditableAspect$SetAuditProperties.doWork(Aud
itableAspect.java:264)
        at org.alfresco.repo.audit.AuditableAspect$SetAuditProperties.doWork(Aud
itableAspect.java:237)
        at org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(Au
thenticationUtil.java:252)
        at org.alfresco.repo.audit.AuditableAspect.onUpdateAudit(AuditableAspect
.java:190)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.alfresco.repo.policy.JavaBehaviour$JavaMethodInvocationHandler.in
voke(JavaBehaviour.java:179)
        at $Proxy49.onUpdateNode(Unknown Source)
        at sun.reflect.GeneratedMethodAccessor296.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.alfresco.repo.policy.TransactionBehaviourQueue.execute(Transactio
nBehaviourQueue.java:189)
        … 13 more


The relevant part of the class looks like this:


public void initialise()
    {
        // Register the policy behaviours
        this.policyComponent.bindClassBehaviour(
                                 ContentServicePolicies.ON_CONTENT_READ,
                                 Constants.ASPECT_PUBLIKACIJA,
                                 new JavaBehaviour(this, "onContentRead", NotificationFrequency.TRANSACTION_COMMIT));  
    }

   
   
    /**
     * onContentRead policy behaviour.
     *
     */
    public void onContentRead(NodeRef nodeRef){
       try
        {
          this.nodeService.setProperty(nodeRef, Constants.PROP_POSLEDNJIPRISTUP, new Date());
           
        }
        catch(Exception e)
        {
          
        }
       
    }

Thanks in advance,

Dragan

Outcomes