<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Associate a Comment with a UserTask at creation time? in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/associate-a-comment-with-a-usertask-at-creation-time/m-p/142076#M99505</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes, I do see the logging get printed.&amp;nbsp; The listener fires, but nothing gets persisted to the db.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you think there's a chance this may be related to the older version of Activiti, I can try again with the newest version.&amp;nbsp; Unfortunately the client is on 5.10 and isn't ready to upgrade, but at least we'll know then.&amp;nbsp; Thanks for the heads-up.&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 16 Apr 2013 14:48:43 GMT</pubDate>
    <dc:creator>mindcrime</dc:creator>
    <dc:date>2013-04-16T14:48:43Z</dc:date>
    <item>
      <title>Associate a Comment with a UserTask at creation time?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/associate-a-comment-with-a-usertask-at-creation-time/m-p/142074#M99503</link>
      <description>Hi all, quick question… my client has a requirement regarding tracking history which seems to map well to the Commentsfacility.&amp;nbsp; As such, I'm trying to associate a comment with a UserTask from within a TaskListener which is bound to the "create" event.&amp;nbsp; My code looks like this&lt;IMG id="smileytongue" class="emoticon emoticon-smileytongue" src="https://migration33.stage.lithium.com/i/smilies/16x16_smiley-tongue.png" alt="Smiley Tongue" title="Smiley Tongue" /&gt;ublic class AddInitia</description>
      <pubDate>Mon, 15 Apr 2013 21:29:43 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/associate-a-comment-with-a-usertask-at-creation-time/m-p/142074#M99503</guid>
      <dc:creator>mindcrime</dc:creator>
      <dc:date>2013-04-15T21:29:43Z</dc:date>
    </item>
    <item>
      <title>Re: Associate a Comment with a UserTask at creation time?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/associate-a-comment-with-a-usertask-at-creation-time/m-p/142075#M99504</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;And you do see the logging being printed out?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I remember we fixed something a few months ago about calling services in listener. I don't know if that already works in Activiti 5.10.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Apr 2013 10:41:31 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/associate-a-comment-with-a-usertask-at-creation-time/m-p/142075#M99504</guid>
      <dc:creator>jbarrez</dc:creator>
      <dc:date>2013-04-16T10:41:31Z</dc:date>
    </item>
    <item>
      <title>Re: Associate a Comment with a UserTask at creation time?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/associate-a-comment-with-a-usertask-at-creation-time/m-p/142076#M99505</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes, I do see the logging get printed.&amp;nbsp; The listener fires, but nothing gets persisted to the db.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you think there's a chance this may be related to the older version of Activiti, I can try again with the newest version.&amp;nbsp; Unfortunately the client is on 5.10 and isn't ready to upgrade, but at least we'll know then.&amp;nbsp; Thanks for the heads-up.&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Apr 2013 14:48:43 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/associate-a-comment-with-a-usertask-at-creation-time/m-p/142076#M99505</guid>
      <dc:creator>mindcrime</dc:creator>
      <dc:date>2013-04-16T14:48:43Z</dc:date>
    </item>
    <item>
      <title>Re: Associate a Comment with a UserTask at creation time?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/associate-a-comment-with-a-usertask-at-creation-time/m-p/142077#M99506</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes - I do think there might be a transaction issue which was fixed for 5.11 I believe.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Apr 2013 09:13:18 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/associate-a-comment-with-a-usertask-at-creation-time/m-p/142077#M99506</guid>
      <dc:creator>jbarrez</dc:creator>
      <dc:date>2013-04-18T09:13:18Z</dc:date>
    </item>
    <item>
      <title>Re: Associate a Comment with a UserTask at creation time?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/associate-a-comment-with-a-usertask-at-creation-time/m-p/142078#M99507</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;OK, trying this with 5.11, I still don't get my Comment saved, but at least I get an Exception that points in the direction of what's happening.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's the code for the TaskListener.&amp;nbsp; Pretty straightforward:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;CODE&gt;&lt;BR /&gt;public class SimpleTaskListener511 implements TaskListener&lt;BR /&gt;{&lt;BR /&gt; &lt;BR /&gt; @Override&lt;BR /&gt; public void notify( DelegateTask task ) &lt;BR /&gt; {&lt;BR /&gt;&amp;nbsp; System.out.println( "in SimpleTaskListener511" );&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;&amp;nbsp; TaskService taskService = task.getExecution().getEngineServices().getTaskService();&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;&amp;nbsp; taskService.addComment(task.getId(), null, "Initial comment added at create time" );&lt;BR /&gt;&amp;nbsp; System.out.println( "added comment!" );&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;/CODE&gt;&lt;BR /&gt;&lt;SPAN&gt;And when this Listener fires, here's what happens:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;CODE&gt;&lt;BR /&gt;INFO: Processing resource SimpleProcess511.simpleProcess.png&lt;BR /&gt;Made it here..&lt;BR /&gt;in SimpleTaskListener511&lt;BR /&gt;added comment!&lt;BR /&gt;Apr 22, 2013 12:51:33 PM org.activiti.engine.impl.interceptor.CommandContext close&lt;BR /&gt;SEVERE: Error while closing command context&lt;BR /&gt;org.activiti.engine.ActivitiException: Cannot find task with id 305&lt;BR /&gt; at org.activiti.engine.impl.cmd.NeedsActiveTaskCmd.execute(NeedsActiveTaskCmd.java:51)&lt;BR /&gt; at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24)&lt;BR /&gt; at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:60)&lt;BR /&gt; at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:32)&lt;BR /&gt; at org.activiti.engine.impl.TaskServiceImpl.addComment(TaskServiceImpl.java:259)&lt;BR /&gt; at org.example.activiti.SimpleTaskListener511.notify(SimpleTaskListener511.java:17)&lt;BR /&gt; at org.activiti.engine.impl.delegate.TaskListenerInvocation.invoke(TaskListenerInvocation.java:34)&lt;BR /&gt; at org.activiti.engine.impl.delegate.DelegateInvocation.proceed(DelegateInvocation.java:37)&lt;BR /&gt; at org.activiti.engine.impl.delegate.DefaultDelegateInterceptor.handleInvocation(DefaultDelegateInterceptor.java:25)&lt;BR /&gt; at org.activiti.engine.impl.bpmn.helper.ClassDelegate.notify(ClassDelegate.java:92)&lt;BR /&gt; at org.activiti.engine.impl.delegate.TaskListenerInvocation.invoke(TaskListenerInvocation.java:34)&lt;BR /&gt; at org.activiti.engine.impl.delegate.DelegateInvocation.proceed(DelegateInvocation.java:37)&lt;BR /&gt; at org.activiti.engine.impl.delegate.DefaultDelegateInterceptor.handleInvocation(DefaultDelegateInterceptor.java:25)&lt;BR /&gt; at org.activiti.engine.impl.persistence.entity.TaskEntity.fireEvent(TaskEntity.java:525)&lt;BR /&gt; at org.activiti.engine.impl.bpmn.behavior.UserTaskActivityBehavior.execute(UserTaskActivityBehavior.java:94)&lt;BR /&gt; at org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(AtomicOperationActivityExecute.java:44)&lt;BR /&gt; at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:85)&lt;BR /&gt; at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:535)&lt;BR /&gt; at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:530)&lt;BR /&gt; at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerStart.eventNotificationsCompleted(AtomicOperationTransitionNotifyListenerStart.java:52)&lt;BR /&gt; at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:56)&lt;BR /&gt; at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:85)&lt;BR /&gt; at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:535)&lt;BR /&gt; at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:530)&lt;BR /&gt; at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:49)&lt;BR /&gt; at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:85)&lt;BR /&gt; at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:535)&lt;BR /&gt; at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:530)&lt;BR /&gt; at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionCreateScope.execute(AtomicOperationTransitionCreateScope.java:49)&lt;BR /&gt; at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:85)&lt;BR /&gt; at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:535)&lt;BR /&gt; at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:530)&lt;BR /&gt; at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerTake.execute(AtomicOperationTransitionNotifyListenerTake.java:65)&lt;BR /&gt; at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:85)&lt;BR /&gt; at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:535)&lt;BR /&gt; at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:530)&lt;BR /&gt; at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionDestroyScope.execute(AtomicOperationTransitionDestroyScope.java:115)&lt;BR /&gt; at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:85)&lt;BR /&gt; at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:535)&lt;BR /&gt; at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:530)&lt;BR /&gt; at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerEnd.eventNotificationsCompleted(AtomicOperationTransitionNotifyListenerEnd.java:36)&lt;BR /&gt; at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:56)&lt;BR /&gt;…&lt;BR /&gt;&lt;/CODE&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Apr 2013 17:57:15 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/associate-a-comment-with-a-usertask-at-creation-time/m-p/142078#M99507</guid>
      <dc:creator>mindcrime</dc:creator>
      <dc:date>2013-04-22T17:57:15Z</dc:date>
    </item>
    <item>
      <title>Re: Associate a Comment with a UserTask at creation time?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/associate-a-comment-with-a-usertask-at-creation-time/m-p/142079#M99508</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;OK, one more quick note on this.&amp;nbsp; It does appear to be a transaction scoping issue.&amp;nbsp; I'm guessing the taskService call is starting a new transaction, which can't read the current Task as the transaction it is created in doesn't commit until sometime after the Listener's notify() method returns.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, if you do something like this, to allow the Listener to finish, but push creating the Comment out until a few milliseconds later, it works as expected:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;CODE&gt;&lt;BR /&gt;public class SimpleTaskListener511 implements TaskListener&lt;BR /&gt;{&lt;BR /&gt; &lt;BR /&gt; @Override&lt;BR /&gt; public void notify( DelegateTask task ) &lt;BR /&gt; {&lt;BR /&gt;&amp;nbsp; System.out.println( "in SimpleTaskListener511" );&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;&amp;nbsp; TaskService taskService = task.getExecution().getEngineServices().getTaskService();&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;&amp;nbsp; Thread thread = new Thread( new CommentAdder( task, taskService));&lt;BR /&gt;&amp;nbsp; thread.start();&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;class CommentAdder implements Runnable&lt;BR /&gt;{&lt;BR /&gt; DelegateTask task;&lt;BR /&gt; TaskService taskService;&lt;BR /&gt; &lt;BR /&gt; public CommentAdder( DelegateTask task, TaskService taskService )&lt;BR /&gt; {&lt;BR /&gt;&amp;nbsp; this.task = task;&lt;BR /&gt;&amp;nbsp; this.taskService = taskService;&lt;BR /&gt; }&lt;BR /&gt; &lt;BR /&gt; public void run()&lt;BR /&gt; {&lt;BR /&gt;&amp;nbsp; try&lt;BR /&gt;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp; Thread.sleep( 3000 );&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp; catch( Exception e ) {}&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;&amp;nbsp; taskService.addComment(task.getId(), null, "Initial comment added at create time" );&lt;BR /&gt;&amp;nbsp; System.out.println( "added comment!" );&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt; }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;BR /&gt;&lt;SPAN&gt;My question is, *should* you be able to create a Comment, using the TaskService, in the scope of the notify() method on a Listener like that?&amp;nbsp; I'm planning to try this again with 5.12 just to see if the behaviour has changed but I'd love to hear a definitive word on whether or not this is even a supported operation.&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Apr 2013 18:19:18 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/associate-a-comment-with-a-usertask-at-creation-time/m-p/142079#M99508</guid>
      <dc:creator>mindcrime</dc:creator>
      <dc:date>2013-04-22T18:19:18Z</dc:date>
    </item>
    <item>
      <title>Re: Associate a Comment with a UserTask at creation time?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/associate-a-comment-with-a-usertask-at-creation-time/m-p/142080#M99509</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;FYI, this works in 5.12, with directly calling the taskService from the Listener.&amp;nbsp; Looks like we either have to upgrade, or use the workaround above.&amp;nbsp; &lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Apr 2013 21:09:57 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/associate-a-comment-with-a-usertask-at-creation-time/m-p/142080#M99509</guid>
      <dc:creator>mindcrime</dc:creator>
      <dc:date>2013-04-22T21:09:57Z</dc:date>
    </item>
  </channel>
</rss>

