IllegalArgumentException when trying to init the procActionsFrame with a BaseStringIdEntity entity reference

Hello!

I get this error from a deployed bpm process when I try to access the edit screen of an entity:

IllegalArgumentException: You have attempted to set a value of type class java.lang.String for parameter entityId with expected type of class java.util.UUID from query string select pi from bpm$ProcInstance pi where pi.procDefinition.id = :procDefinition and pi.entityId = :entityId.

This is my entity:

public class Building extends BaseStringIdEntity implements HasUuid {
    private static final long serialVersionUID = 8474095780417145277L;

    @Column(name = "UUID", nullable = false)
    protected UUID uuid;

    @Id
    @CaseConversion
    @NotNull
    @Column(name = "BUILDING_ID", nullable = false, unique = true, length = 16)
    protected String building_id;

    @NotNull
    @Column(name = "STATUS", nullable = false)
    protected String status = BuildingStatus.ACTIVE.name();

    @Override
    public void setUuid(UUID uuid) {
        this.uuid = uuid;
    }

    @Override
    public UUID getUuid() {
        return uuid;
    }

    @Override
    public String getId() {
        return this.building_id;
    }

    @Override
    public void setId(String id) {
        this.building_id = id;
    }

    public void setStatus(BuildingStatus status) {
        this.status = status == null ? null : status.getId();
    }

    public BuildingStatus getStatus() {
        return status == null ? null : BuildingStatus.fromId(status);
    }
}

This is the class from which I call an operation on the entity through a server task declared in the bpm model:

@Component("BuildingHelperBean")
public class BuildingHelper {

    @Inject
    private Persistence persistence;

    public void updateStatus(String entityId, String statusId) {
        try (Transaction tx = persistence.getTransaction()) {
            Building building = persistence.getEntityManager().find(Building.class, entityId);
            if (building != null) {
                building.setStatus(BuildingStatus.fromId(statusId));
            }
            tx.commit();
        }
    }

}

This is the editor screen controller:

public class BuildingEdit extends AbstractEditor<Building> {
    public static final String PROC_CODE = "buildingInspection";

    @Inject
    private ProcActionsFrame procActionsFrame;

    @Override
    protected void postInit() {
        initProcActionsFrame();
    }

    private void initProcActionsFrame() {
        procActionsFrame.initializer()
                .setBeforeStartProcessPredicate(this::commit)
                .setAfterStartProcessListener(() -> {
                    showNotification(getMessage("processStarted"), NotificationType.HUMANIZED);
                    close(COMMIT_ACTION_ID);
                })
                .setBeforeCompleteTaskPredicate(this::commit)
                .setAfterCompleteTaskListener(() -> {
                    showNotification(getMessage("taskCompleted"), NotificationType.HUMANIZED);
                    close(COMMIT_ACTION_ID);
                })
                .init(PROC_CODE, getItem());
    }
}

From a quick glance inside the app log, the error seems to be coming from procActionsFrame.init(PROC_CODE, getItem()).
Inside the init method I found that it requires a Uuid implementation and it calls the getUuid method of the entity so it should not confuse my primary key (which is String) with the uuid.
What is the problem and how to fix it ?
Thanks.

Hi,
that’s a bug. If the entity has a primary key that is not of UUID type, some BPM UI frames throw an exception. The issue: https://youtrack.cuba-platform.com/issue/PL-10139

1 Like

Hi,
thanks for clearing that up. I was wasting too much time on it.

Hi,
The issue is fixed in the platform version 6.7.6.

Hi, the changes made in the issue https://youtrack.cuba-platform.com/issue/PL-10139 (replacing the entityId property in the ProcInstace with the reference to embedded entity) shouldn’t have been merged to the release 6.7 because they break the backward compatibility. In the next bugfix release 6.7.7 the changes will be reverted. The https://youtrack.cuba-platform.com/issue/PL-10139 will be fixed in the release 6.8. Sorry for the inconvenience.
The issue: https://youtrack.cuba-platform.com/issue/PL-10213