<?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 NPE on historicVariableInstance.getValue in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/npe-on-historicvariableinstance-getvalue/m-p/161090#M115043</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;SPAN&gt;I've a process definition which is consisting of service tasks so there is no wait state in it. After calling &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="language-java line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;startProcessInstanceByKey(processDefinitionKey, map);&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;process starts, ends and return. After returning, I'm trying to access a variable which I gave in the map parameter. The parameter I'm trying to access is a custom object implementing Serializable interface. I use that query:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-java line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;NativeHistoricVariableInstanceQuery historicVariableInstanceQuery = historyService.createNativeHistoricVariableInstanceQuery();&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;historicVariableInstanceQuery.sql("SELECT * FROM " + managementService.getTableName(HistoricVariableInstance.class) +&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;" WHERE EXECUTION_ID_=#{executionId} AND NAME_=#{variableName}");&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;historicVariableInstanceQuery.parameter("executionId", executionId);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;historicVariableInstanceQuery.parameter("variableName", variableName);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;HistoricVariableInstance historicVariableInstance = historicVariableInstanceQuery.singleResult();&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (historicVariableInstance != null) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return (T) historicVariableInstance.getValue();&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;return null;&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;At the line &lt;/SPAN&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;return&amp;nbsp; (T) historicVariableInstance.getValue();&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;SPAN&gt;(SimpleActivitiQueryService.java:65) I get a NPE:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-java line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;java.lang.NullPointerException&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;at org.activiti.engine.impl.persistence.entity.ByteArrayRef.ensureInitialized(ByteArrayRef.java:93)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;at org.activiti.engine.impl.persistence.entity.ByteArrayRef.getBytes(ByteArrayRef.java:46)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;at org.activiti.engine.impl.persistence.entity.HistoricVariableInstanceEntity.getBytes(HistoricVariableInstanceEntity.java:123)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;at org.activiti.engine.impl.variable.ByteArrayType.getValue(ByteArrayType.java:32)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;at org.activiti.engine.impl.variable.SerializableType.getValue(SerializableType.java:51)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;at org.activiti.engine.impl.persistence.entity.HistoricVariableInstanceEntity.getValue(HistoricVariableInstanceEntity.java:114)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;at myPkg.SimpleActivitiQueryService.findLastValueOfVariable(SimpleActivitiQueryService.java:65)&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It seems that at &lt;/SPAN&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;ByteArrayRef.java:93&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;Context.getCommandContext()&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;SPAN&gt; is null.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've seen some possibly related links but I'm not sure if they about this issue or not:&lt;/SPAN&gt;&lt;BR /&gt;&lt;UL&gt;&lt;LI&gt;&lt;A href="http://forums.activiti.org/content/npe-variables-get-processinstance-loaded-processinstancequery" rel="nofollow noopener noreferrer"&gt;http://forums.activiti.org/content/npe-variables-get-processinstance-loaded-processinstancequery&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;&lt;A href="http://forums.activiti.org/content/npe-retrieving-blob-local-task-variable" rel="nofollow noopener noreferrer"&gt;http://forums.activiti.org/content/npe-retrieving-blob-local-task-variable&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 20 Jan 2014 13:14:15 GMT</pubDate>
    <dc:creator>gokceng1</dc:creator>
    <dc:date>2014-01-20T13:14:15Z</dc:date>
    <item>
      <title>NPE on historicVariableInstance.getValue</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/npe-on-historicvariableinstance-getvalue/m-p/161090#M115043</link>
      <description>Hi,I've a process definition which is consisting of service tasks so there is no wait state in it. After calling startProcessInstanceByKey(processDefinitionKey, map);‍‍‍process starts, ends and return. After returning, I'm trying to access a variable which I gave in the map parameter. The parameter</description>
      <pubDate>Mon, 20 Jan 2014 13:14:15 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/npe-on-historicvariableinstance-getvalue/m-p/161090#M115043</guid>
      <dc:creator>gokceng1</dc:creator>
      <dc:date>2014-01-20T13:14:15Z</dc:date>
    </item>
    <item>
      <title>Re: NPE on historicVariableInstance.getValue</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/npe-on-historicvariableinstance-getvalue/m-p/161091#M115044</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;I created small jUnit test for it. - Result is the same. I will have a look on it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://github.com/martin-grofcik/Activiti/blob/forum-NPE/modules/activiti-engine/src/test/java/org/activiti/engine/test/api/history/HistoryServiceTest.java" rel="nofollow noopener noreferrer"&gt;https://github.com/martin-grofcik/Activiti/blob/forum-NPE/modules/activiti-engine/src/test/java/org/activiti/engine/test/api/history/HistoryServiceTest.java&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;testNativeHistoricVariableInstanceQuery&lt;/SPAN&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>Tue, 21 Jan 2014 08:10:03 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/npe-on-historicvariableinstance-getvalue/m-p/161091#M115044</guid>
      <dc:creator>martin_grofcik</dc:creator>
      <dc:date>2014-01-21T08:10:03Z</dc:date>
    </item>
    <item>
      <title>Re: NPE on historicVariableInstance.getValue</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/npe-on-historicvariableinstance-getvalue/m-p/161092#M115045</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I've used this code at 5.13 but hadn't faced with a problem. Don't know if this helps.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you martin.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Jan 2014 10:09:03 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/npe-on-historicvariableinstance-getvalue/m-p/161092#M115045</guid>
      <dc:creator>gokceng1</dc:creator>
      <dc:date>2014-01-21T10:09:03Z</dc:date>
    </item>
    <item>
      <title>Re: NPE on historicVariableInstance.getValue</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/npe-on-historicvariableinstance-getvalue/m-p/161093#M115046</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello martin,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there any news about this issue?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Jan 2014 15:48:06 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/npe-on-historicvariableinstance-getvalue/m-p/161093#M115046</guid>
      <dc:creator>gokceng1</dc:creator>
      <dc:date>2014-01-29T15:48:06Z</dc:date>
    </item>
    <item>
      <title>Re: NPE on historicVariableInstance.getValue</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/npe-on-historicvariableinstance-getvalue/m-p/161094#M115047</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you, and sorry - I did not have time to look at it. But basically the problem is that value retrieval is not done in the activiti command context. That's why value is not fetched from the cache and request to the DB is executed without command context. One possibility is to fetch value in the native query select command (join with ACT_GE_BYTEARRAY table). Could you try it please?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jan 2014 07:24:11 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/npe-on-historicvariableinstance-getvalue/m-p/161094#M115047</guid>
      <dc:creator>martin_grofcik</dc:creator>
      <dc:date>2014-01-30T07:24:11Z</dc:date>
    </item>
  </channel>
</rss>

