AnsweredAssumed Answered

NullPointerException trying to set UserEntity Picture

Question asked by discolo on Apr 12, 2013
Latest reply on Apr 15, 2013 by jbarrez
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 my LDAP.

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:
UserEntity user = new UserEntity(userId);
Attribute photoAttr = entry.get("jpegPhoto");
if(photoAttr != null) {
   user.setPicture(new Picture(photoAttr.getBytes(), "image/jpeg"));
The UserEntity.setPicture method has the following code (lines 83 to 90)
    if (picture!=null) {
      pictureByteArray = new ByteArrayEntity(picture.getMimeType(), picture.getBytes());
      pictureByteArrayId = pictureByteArray.getId();
    } else {
When Context.getCommandContext() is executed null is returned with the consequent Nullpointerexception.

My questions are:
- Would it be a good idea to prevent this nullpointerexception raising some exception or performing null check?
- Why the getStack(commandContextThreadLocal) method returns an empty Stack?

If some extra information is needed just ask.

Thanks in advance and kind regards,