Embedded entites through REST query

Hi guys,

I am getting the following error when trying to do a REST query on an entity with an embedded entity.

16:34:36.687 ERROR c.h.r.c.RestControllerExceptionHandler - Exception in REST controller
java.lang.ClassCastException: com.daryn.ecosmart.entity.AddressEmbeddable cannot be cast to com.haulmont.cuba.core.entity.BaseGenericIdEntity
    at com.haulmont.restapi.common.RestControllerUtils$FillingInaccessibleAttributesVisitor.visit(RestControllerUtils.java:113)

Any ideas?

Hi,
your user probably has a role that denies an access to one of embedded entity attributes. We’ve created an issue: Exception when loading the embedded entity with inaccessible attribute · Issue #72 · cuba-platform/restapi · GitHub

I think it is just a bug. User definitely has the right role.
I have converted to a standard entity instead of embedded to resolve.

Best,
Daryn

You say that the user doesn’t have a role that denies access to entity attribute? Could you please check? According to the piece of the stacktrace from your initial message, the exception occurs at RestControllerUtils, line 113.

        public void visit(Entity entity, MetaProperty property) {
            MetaClass metaClass = metadata.getClassNN(entity.getClass());
            if (!security.isEntityAttrReadPermitted(metaClass, property.getName())) {
                addInaccessibleAttribute((BaseGenericIdEntity) entity, property.getName());
// .....
            }

The execution comes to the line 113

addInaccessibleAttribute((BaseGenericIdEntity) entity, property.getName());

only if there is an inaccessible attribute

!security.isEntityAttrReadPermitted(metaClass, property.getName())

You can put a breakpoint at line 113 and see what property is not allowed for reading.