Avoid NPE by validating entity.  Provide meaningful error messages to the user and log them as well.