<?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: @Autowired private RuntimeService runtimeService; is giving null in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/autowired-private-runtimeservice-runtimeservice-is-giving-null/m-p/218181#M171311</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;There is a typo in the last line code&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;code&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;runtimeService.setVariable(processInstance.getId(), "emitraEntity", emitraEntity);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/code&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It is actually &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;code&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;runtimeService.setVariable(processInstance.getId(), "emEntity", emEntity);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/code&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Problem still prevails.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 29 Apr 2016 17:53:50 GMT</pubDate>
    <dc:creator>logicallimit</dc:creator>
    <dc:date>2016-04-29T17:53:50Z</dc:date>
    <item>
      <title>@Autowired private RuntimeService runtimeService; is giving null</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/autowired-private-runtimeservice-runtimeservice-is-giving-null/m-p/218180#M171310</link>
      <description>I am trying to build a spring web mvc application using Activiti 5.19.0.2.When I try to call Activiti API from a java class&amp;nbsp; where I use @Autowired to get instance of activity engine, I am getting null. Am I missing something in my following code.mvc-dispatcher-servlet.xml&amp;lt;!– Activiti related bea</description>
      <pubDate>Fri, 29 Apr 2016 17:46:23 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/autowired-private-runtimeservice-runtimeservice-is-giving-null/m-p/218180#M171310</guid>
      <dc:creator>logicallimit</dc:creator>
      <dc:date>2016-04-29T17:46:23Z</dc:date>
    </item>
    <item>
      <title>Re: @Autowired private RuntimeService runtimeService; is giving null</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/autowired-private-runtimeservice-runtimeservice-is-giving-null/m-p/218181#M171311</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;There is a typo in the last line code&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;code&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;runtimeService.setVariable(processInstance.getId(), "emitraEntity", emitraEntity);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/code&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It is actually &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;code&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;runtimeService.setVariable(processInstance.getId(), "emEntity", emEntity);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/code&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Problem still prevails.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Apr 2016 17:53:50 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/autowired-private-runtimeservice-runtimeservice-is-giving-null/m-p/218181#M171311</guid>
      <dc:creator>logicallimit</dc:creator>
      <dc:date>2016-04-29T17:53:50Z</dc:date>
    </item>
    <item>
      <title>Re: @Autowired private RuntimeService runtimeService; is giving null</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/autowired-private-runtimeservice-runtimeservice-is-giving-null/m-p/218182#M171312</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can you create jUnit test?&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="https://forums.activiti.org/content/sticky-how-write-unit-test" rel="nofollow noopener noreferrer"&gt;https://forums.activiti.org/content/sticky-how-write-unit-test&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Martin&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 May 2016 04:46:32 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/autowired-private-runtimeservice-runtimeservice-is-giving-null/m-p/218182#M171312</guid>
      <dc:creator>martin_grofcik</dc:creator>
      <dc:date>2016-05-02T04:46:32Z</dc:date>
    </item>
    <item>
      <title>Re: @Autowired private RuntimeService runtimeService; is giving null</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/autowired-private-runtimeservice-runtimeservice-is-giving-null/m-p/218183#M171313</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the reply Martin. I was able to solve the problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Let me brief about it. There is a service class from where I call the class where Activiti related logic is put up.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;code&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;@Service&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;@Transactional&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;public class EmServiceImpl implements EmService {&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; public EmServiceImpl() {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; System.out.println("EmServiceImpl");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; @Autowired&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; private EmDAO emDAO;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; @Autowired&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; private ActivitiRuntimeService activitiRuntimeService;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; public long createEm(EmEntity emEntity) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; long applicationNo = emDAO.insertEm(emEntity);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; activitiRuntimeService.startProcess(emEntity);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; return applicationNo;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/code&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;code&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;@Service&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;@Transactional&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;public class ActivitiRuntimeService {&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; public ActivitiRuntimeService() {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; // TODO Auto-generated constructor stub&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; @Autowired&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; private RuntimeService runtimeService;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; @Autowired&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; private RepositoryService repositoryService;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; @Transactional&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; public void startProcess(EmEntity emEntity){&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; Map&amp;lt;String, Object&amp;gt; variables = new HashMap&amp;lt;String, Object&amp;gt;();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; variables.put("emEntity", emEntity);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; repositoryService.createDeployment().name("Em Test").addInputStream("em-test.bpmn20.xml", ReflectUtil.getResourceAsStream("diagrams/em-test.bpmn")).deploy();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; @SuppressWarnings("unused")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("em-test", variables);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/code&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The above code is corrected code. The problem was that in the service class "EmServiceImpl", I was also creating an object of my custom Activiti related class "ActivitiRuntimeService" through code by calling default constructor. And hence it was probably confusing Spring container and the object was ultimately not even initialized and was null. It was a very kiddish mistake indeed!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, when we are autowiring to get automatic object, then need to check we are not creating explicit object also in the calling code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 May 2016 06:49:42 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/autowired-private-runtimeservice-runtimeservice-is-giving-null/m-p/218183#M171313</guid>
      <dc:creator>logicallimit</dc:creator>
      <dc:date>2016-05-02T06:49:42Z</dc:date>
    </item>
  </channel>
</rss>

