cancel
Showing results for 
Search instead for 
Did you mean: 

rule executed in abckground does not work

gandrez
Champ in-the-making
Champ in-the-making
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
8 REPLIES 8

andy
Champ on-the-rise
Champ on-the-rise
Hi

This looks like a bug to me.
Do you always see this type of error?

Could you raise a JIRA issue.

Cheers

Andy

gandrez
Champ in-the-making
Champ in-the-making
Hello Andy

I have raised an issue as you suggested at

http://issues.alfresco.com/browse/AR-1456

Yes, the exception is thrown every time I access a document which has this aspect applied. I've also noticed a pattern. It gets thrown on a 1 minute basis. If I access any number of documents with this aspect applied in a time frame before the next time this (I think) job scheduler checks, a single exception is thrown. If I don't access any document within the next 60 seconds, the exception is not thrown. Of course when I access a document again at any point after that, everything repeats.

Regards,

Dragan

gandrez
Champ in-the-making
Champ in-the-making
Hello Andy!

A small update:

So far I've been using Alfresco 2.0 CE with Tomcat bundle and HSQL.

After I deployed the application to a stand-alone Tomcat server and switched to MySQL the exceptions do not appear anymore.

Best regards,

Dragan

tpasturel
Champ in-the-making
Champ in-the-making
Hi,

I have the same problem. A custom aspect is applied to each document. When a document is read or updated the same error is thrown.

There is no correlation with a backgroung executing rule.

The problem is linked with custom apect behaviours.


Since the bug appeared, a new message is sometimes written in the output console :

### Excluding compile:  org.apache.lucene.index.IndexReader$1::doBody

andy
Champ on-the-rise
Champ on-the-rise
Hi

The issue is the indexer is reading content while doing background indexing - if this index changes attributes - it will need to reindex. The fix will be to reindex without binding the onReadContent  policy. The fix is not in yet.

However, whatever you are trying to do is probably flawed. I would guess you want to count access or audit access.

In the first case caching/or not makes the numbers pretty pointless. Also, the windows CIFS client opens files threee times for a read and access to properties will open the content many times.

If it is for audit - then getting the content means nothing with regard to proving someone has read it …or that someone else has not read it - for I have email, a printer, …..

So I have to ask, what are you trying to do?

Andy

tpasturel
Champ in-the-making
Champ in-the-making
Hi,

   there are two aspects applied to each document. One for metadatas and the second is the ContentHitsAspect sample from the sdk.

   For us, the purpose of the contenhits aspect is to have an audit of the content access by users (onReadContent). Not to have the exact number of content readings but to compare the different spaces success.
   The onUpdateContent behaviour has been deleted because it was called on each reading.
 
   CIFS is deactivated.

   The bug disappeared once on a tomcat reboot without source changes (only a larger jvm memory), and the next reboot reappeared.

   The documents are well indexed, but the big problem with that bug is that the memory is not well deallocated and the jvm heap oversizes in one day of using (1.5 GB alllocated).

Regards,
                           Thomas

tpasturel
Champ in-the-making
Champ in-the-making
The problem was on the contenthits aspect.

During the onReadContent, not only onUpdateContent behaviour from the contenthits class should be deactivated, but also AuditableAspect update behaviour ! Indeed, the update of a document property also calls auditableaspect update behaviour.

tpasturel
Champ in-the-making
Champ in-the-making
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…

Auditable Aspect onUpdateNode behaviour deactivation is not sufficient because setProperty implementation constraints the call of the behaviour call :

DBNodeServiceImpl v2.0
  public void setProperty(NodeRef nodeRef, QName qname, Serializable value) throws InvalidNodeRefException
    {
        Assert.notNull(qname);
       
        // Invoke policy behaviours
      invokeBeforeUpdateNode(nodeRef);
      
        […]

      // Invoke policy behaviours
      invokeOnUpdateNode(nodeRef);
        invokeOnUpdateProperties(nodeRef, propertiesBefore, propertiesAfter);
    }