<?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 NullPointerException trying to set UserEntity Picture in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/nullpointerexception-trying-to-set-userentity-picture/m-p/139416#M97704</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This is my first question, so I'm very new with Activiti, hope somebody could help me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm developing some LDAP identity management integration for Activiti, starting from some examples (blogs and book). I've implemented the UserEntityManager class in order to retrieve and validate users from my LDAP.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;All this is being tested using JUnit and an Inmemory LDAP with an Spring context configured (activiti 5.12). The problem comes when I try to retrieve the user's picture, like follows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;UserEntity user = new UserEntity(userId);&lt;BR /&gt;user.setEmail(entry.get("mail").getString());&lt;BR /&gt;user.setLastName(entry.get("sn").getString());&lt;BR /&gt;user.setFirstName(entry.get("givenName").getString());&lt;BR /&gt;Attribute photoAttr = entry.get("jpegPhoto");&lt;BR /&gt;if(photoAttr != null) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;user.setPicture(new Picture(photoAttr.getBytes(), "image/jpeg"));&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;/CODE&gt;&lt;/PRE&gt;&lt;SPAN&gt;The UserEntity.setPicture method has the following code (lines 83 to 90)&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (picture!=null) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pictureByteArray = new ByteArrayEntity(picture.getMimeType(), picture.getBytes());&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Context&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .getCommandContext()&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .getDbSqlSession()&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .insert(pictureByteArray);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pictureByteArrayId = pictureByteArray.getId();&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } else {&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;/CODE&gt;&lt;/PRE&gt;&lt;SPAN&gt;When Context.getCommandContext() is executed null is returned with the consequent Nullpointerexception.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My questions are:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- Would it be a good idea to prevent this nullpointerexception raising some exception or performing null check?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- Why the getStack(commandContextThreadLocal) method returns an empty Stack?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If some extra information is needed just ask.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance and kind regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Rubén.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 12 Apr 2013 12:05:25 GMT</pubDate>
    <dc:creator>discolo</dc:creator>
    <dc:date>2013-04-12T12:05:25Z</dc:date>
    <item>
      <title>NullPointerException trying to set UserEntity Picture</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/nullpointerexception-trying-to-set-userentity-picture/m-p/139416#M97704</link>
      <description>Hi all,This is my first question, so I'm very new with Activiti, hope somebody could help me.I'm developing some LDAP identity management integration for Activiti, starting from some examples (blogs and book). I've implemented the UserEntityManager class in order to retrieve and validate users from</description>
      <pubDate>Fri, 12 Apr 2013 12:05:25 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/nullpointerexception-trying-to-set-userentity-picture/m-p/139416#M97704</guid>
      <dc:creator>discolo</dc:creator>
      <dc:date>2013-04-12T12:05:25Z</dc:date>
    </item>
    <item>
      <title>Re: NullPointerException trying to set UserEntity Picture</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/nullpointerexception-trying-to-set-userentity-picture/m-p/139417#M97705</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The picture need to be set through the identityService:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; void setUserPicture(String userId, Picture picture);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That is also why the setPicture method is not exposed on the org.activiti.engine.identity.User class.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Apr 2013 09:44:43 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/nullpointerexception-trying-to-set-userentity-picture/m-p/139417#M97705</guid>
      <dc:creator>jbarrez</dc:creator>
      <dc:date>2013-04-15T09:44:43Z</dc:date>
    </item>
  </channel>
</rss>

