<?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: How do I get the current ProcessInstance in SpringBean? in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/how-do-i-get-the-current-processinstance-in-springbean/m-p/79402#M52840</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Looking at the spring examples that ship with activiti, I think all I need to do is implement JavaDelegate and change my ServiceTask from an expression (which was working) to a DelegateExpression in the model. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I did that, and implemented JavaDelegate.&amp;nbsp; When I execute the workflow, I get an error&lt;/SPAN&gt;&lt;BR /&gt;&lt;CODE&gt;&lt;BR /&gt;Wrapped Exception (with status template): Delegate expression ${taskBean} did not resolve to an implementation of interface org.activiti.engine.impl.pvm.delegate.ActivityBehavior nor interface org.activiti.engine.delegate.JavaDelegate &lt;BR /&gt;&lt;/CODE&gt;&lt;BR /&gt;&lt;SPAN&gt;When the task is fired.&amp;nbsp; I cannot see how this is any different from the example provided.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My project source is attached.&amp;nbsp; My bean looks like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;CODE&gt;&lt;BR /&gt;public class GetBeanTest implements JavaDelegate {&lt;BR /&gt;&lt;BR /&gt; private ContactService contactService;&lt;BR /&gt; &lt;BR /&gt; public GetBeanTest() {&lt;BR /&gt;&amp;nbsp; super();&lt;BR /&gt; }&lt;BR /&gt; &lt;BR /&gt; public String getContactName(String contactName) throws Exception {&lt;BR /&gt;&amp;nbsp; String retVal= "unknown";&lt;BR /&gt;&amp;nbsp; if(contactService == null){&lt;BR /&gt;&amp;nbsp;&amp;nbsp; System.out.println("Bean was null!");&lt;BR /&gt;&amp;nbsp; }else{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; System.out.println("Bean is valid!");&lt;BR /&gt;&amp;nbsp;&amp;nbsp; List&amp;lt;Contact&amp;gt; contacts= contactService.getContacts();&lt;BR /&gt;&amp;nbsp;&amp;nbsp; System.out.println("There are " + contacts.size() +" in the contact list.");&lt;BR /&gt;&amp;nbsp;&amp;nbsp; for (Contact contact : contacts) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(contact.getName().equalsIgnoreCase(contactName)){&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println("Found the contact! " + contactName );&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; retVal= contact.getEmail();&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp; return retVal;&lt;BR /&gt;&lt;BR /&gt; }&lt;BR /&gt; &lt;BR /&gt; public void setContactService(ContactService contactService) {&lt;BR /&gt;&amp;nbsp; this.contactService = contactService;&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt; @Override&lt;BR /&gt; public void execute(DelegateExecution execution) throws Exception {&lt;BR /&gt;&amp;nbsp; System.out.println("+++++++++++++ in execute ++++++++++++++++");&lt;BR /&gt;&amp;nbsp; System.out.println("Event Name: " + execution.getEventName());&lt;BR /&gt;&amp;nbsp; System.out.println("ID: " + execution.getId());&lt;BR /&gt;&amp;nbsp; System.out.println("Process Instance ID: " + execution.getProcessInstanceId());&lt;BR /&gt;&amp;nbsp; Set&amp;lt;String&amp;gt; varNames= execution.getVariableNames();&lt;BR /&gt;&amp;nbsp; for (String string : varNames) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp; System.out.println("Varible Named " + string + " exists");&lt;BR /&gt;&amp;nbsp;&amp;nbsp; if(string.equalsIgnoreCase("contactName")){&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; String contactName= (String) execution.getVariable(string);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; getContactName(contactName);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; }else{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println("unable to find contact name.");&lt;BR /&gt;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt; }&lt;BR /&gt;}&lt;BR /&gt;&lt;/CODE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 09 Jul 2011 19:16:31 GMT</pubDate>
    <dc:creator>mgriffith</dc:creator>
    <dc:date>2011-07-09T19:16:31Z</dc:date>
    <item>
      <title>How do I get the current ProcessInstance in SpringBean?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-do-i-get-the-current-processinstance-in-springbean/m-p/79401#M52839</link>
      <description>Hello all, I have a ServiceTask in my workflow that resolves to a Spring Managed bean. It looks like this:&amp;lt;serviceTask id="springTask1" name="BeanTest" activiti:expression="${taskBean.execute(contactName)}"&amp;gt;&amp;lt;/serviceTask&amp;gt;‍‍‍I am not starting the process via code, but the process is eithe</description>
      <pubDate>Fri, 08 Jul 2011 22:41:55 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-do-i-get-the-current-processinstance-in-springbean/m-p/79401#M52839</guid>
      <dc:creator>mgriffith</dc:creator>
      <dc:date>2011-07-08T22:41:55Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get the current ProcessInstance in SpringBean?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-do-i-get-the-current-processinstance-in-springbean/m-p/79402#M52840</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Looking at the spring examples that ship with activiti, I think all I need to do is implement JavaDelegate and change my ServiceTask from an expression (which was working) to a DelegateExpression in the model. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I did that, and implemented JavaDelegate.&amp;nbsp; When I execute the workflow, I get an error&lt;/SPAN&gt;&lt;BR /&gt;&lt;CODE&gt;&lt;BR /&gt;Wrapped Exception (with status template): Delegate expression ${taskBean} did not resolve to an implementation of interface org.activiti.engine.impl.pvm.delegate.ActivityBehavior nor interface org.activiti.engine.delegate.JavaDelegate &lt;BR /&gt;&lt;/CODE&gt;&lt;BR /&gt;&lt;SPAN&gt;When the task is fired.&amp;nbsp; I cannot see how this is any different from the example provided.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My project source is attached.&amp;nbsp; My bean looks like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;CODE&gt;&lt;BR /&gt;public class GetBeanTest implements JavaDelegate {&lt;BR /&gt;&lt;BR /&gt; private ContactService contactService;&lt;BR /&gt; &lt;BR /&gt; public GetBeanTest() {&lt;BR /&gt;&amp;nbsp; super();&lt;BR /&gt; }&lt;BR /&gt; &lt;BR /&gt; public String getContactName(String contactName) throws Exception {&lt;BR /&gt;&amp;nbsp; String retVal= "unknown";&lt;BR /&gt;&amp;nbsp; if(contactService == null){&lt;BR /&gt;&amp;nbsp;&amp;nbsp; System.out.println("Bean was null!");&lt;BR /&gt;&amp;nbsp; }else{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; System.out.println("Bean is valid!");&lt;BR /&gt;&amp;nbsp;&amp;nbsp; List&amp;lt;Contact&amp;gt; contacts= contactService.getContacts();&lt;BR /&gt;&amp;nbsp;&amp;nbsp; System.out.println("There are " + contacts.size() +" in the contact list.");&lt;BR /&gt;&amp;nbsp;&amp;nbsp; for (Contact contact : contacts) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(contact.getName().equalsIgnoreCase(contactName)){&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println("Found the contact! " + contactName );&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; retVal= contact.getEmail();&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp; return retVal;&lt;BR /&gt;&lt;BR /&gt; }&lt;BR /&gt; &lt;BR /&gt; public void setContactService(ContactService contactService) {&lt;BR /&gt;&amp;nbsp; this.contactService = contactService;&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt; @Override&lt;BR /&gt; public void execute(DelegateExecution execution) throws Exception {&lt;BR /&gt;&amp;nbsp; System.out.println("+++++++++++++ in execute ++++++++++++++++");&lt;BR /&gt;&amp;nbsp; System.out.println("Event Name: " + execution.getEventName());&lt;BR /&gt;&amp;nbsp; System.out.println("ID: " + execution.getId());&lt;BR /&gt;&amp;nbsp; System.out.println("Process Instance ID: " + execution.getProcessInstanceId());&lt;BR /&gt;&amp;nbsp; Set&amp;lt;String&amp;gt; varNames= execution.getVariableNames();&lt;BR /&gt;&amp;nbsp; for (String string : varNames) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp; System.out.println("Varible Named " + string + " exists");&lt;BR /&gt;&amp;nbsp;&amp;nbsp; if(string.equalsIgnoreCase("contactName")){&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; String contactName= (String) execution.getVariable(string);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; getContactName(contactName);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; }else{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println("unable to find contact name.");&lt;BR /&gt;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt; }&lt;BR /&gt;}&lt;BR /&gt;&lt;/CODE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Jul 2011 19:16:31 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-do-i-get-the-current-processinstance-in-springbean/m-p/79402#M52840</guid>
      <dc:creator>mgriffith</dc:creator>
      <dc:date>2011-07-09T19:16:31Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get the current ProcessInstance in SpringBean?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-do-i-get-the-current-processinstance-in-springbean/m-p/79403#M52841</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Bump.&amp;nbsp; Any suggestions?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Jul 2011 12:29:40 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-do-i-get-the-current-processinstance-in-springbean/m-p/79403#M52841</guid>
      <dc:creator>mgriffith</dc:creator>
      <dc:date>2011-07-11T12:29:40Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get the current ProcessInstance in SpringBean?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-do-i-get-the-current-processinstance-in-springbean/m-p/79404#M52842</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;So if I understand you correctly, you have a working JavaDelegate, and want the process instance, right?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you are using Spring, you don't need to implement any class, you can just do myclass.someMethod(execution), which will pass the current execution, from which you can obtain the current process instance.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Jul 2011 07:59:52 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-do-i-get-the-current-processinstance-in-springbean/m-p/79404#M52842</guid>
      <dc:creator>jbarrez</dc:creator>
      <dc:date>2011-07-19T07:59:52Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get the current ProcessInstance in SpringBean?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-do-i-get-the-current-processinstance-in-springbean/m-p/79405#M52843</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the reply. I didn't realize I could just reference the execution in an expression.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Jul 2011 14:25:51 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-do-i-get-the-current-processinstance-in-springbean/m-p/79405#M52843</guid>
      <dc:creator>mgriffith</dc:creator>
      <dc:date>2011-07-19T14:25:51Z</dc:date>
    </item>
  </channel>
</rss>

