EntitySnapshotAPI getSnapshots doesn't work

Hello. I trying to implement EntitySnapshotAPI to my app and was really surprised that entityServiceAPI getSnapshots() doesn’t work. I wanna track object changes placed on screen and every time i get
java.lang.NullPointerException: null. Help some one to understand this?

public void createMonitoringRouteSnapshot(MonitoringRoute monitoringRoute) {
LOGGER.info(String.format(MessageUtils.CREATE_MONITORING_ROUTE_SNAPSHOT_MESSAGE, monitoringRoute.getId()));
if (monitoringRoute != null)
entitySnapshotAPI.createSnapshot(monitoringRoute, getView());
entitySnapshotAPI.getSnapshots(getMetaClass(), monitoringRoute.getUuid()); //throws null pointer

private MetaClass getMetaClass() {
    return metadata.getClass(MONITORING_ROUTE_ENTITY_NAME);

private View getView() {
    return viewRepository.getView(MonitoringRoute.class, MONITORING_ROUTE_VIEW_NAME);


As exception happens in your code, you should debug it to understand where unexpected null value originates from.

Here are links that can help you start with debugging IntelliJ IDEA:


Hi, Alex. Thanks your answer. After debugging i found trouble place.
Entity entity = dataManager.load(new LoadContext<>(metaClass).setId(id).setView(View.LOCAL)); load null entity(EntitySnapshotManager.class, row 81). But in database in sys_entity_snapshot table stores my entity with entity_id equals id what i put in getSnapshots method. CUBA version - 7.1.2

Probably you are trying to invoke getSnapshots() before the related entity was saved to the database, too early in the entity editor lifecycle.