Добрый день,
После подключения к проекту модуля Dynamic Attributes при вызове REST Entities API возникает ошибка IllegalArgumentException. Проблема воспроизводится в случае, если в параметрах запроса указан fetch plan и для загружаемых связанных сущностей настроены динамические атрибуты. Добавление параметра dynamicAttributes=true решает проблему, но в некоторых сценариях загрузка динамических атрибутов не желательна из соображений производительности.
Тестовый проект, в котором воспроизводится проблема - jmix-petclinic.
Шаги для воспроизвдения пробелмы:
- Добавить динамический атрибут test для сущности PetType.
- Выполнить запрос REST:
curl -X GET http://localhost:8080/rest/entities/petclinic_Pet?fetchPlan=browse \
-H "Accept: application/json" \
-H "Authorization: Bearer ***"
Результат:
Ошибка “java.lang.IllegalArgumentException: Can’t find getter for property ‘+test’ at class io.jmix.petclinic.entity.pet.PetType”
Stacktrace:
java.lang.IllegalArgumentException: Can't find getter for property '+test' at class io.jmix.petclinic.entity.pet.PetType
at io.jmix.core.metamodel.model.utils.MethodsCache.getGetter(MethodsCache.java:179) ~[jmix-core-1.1.3.jar:na]
at io.jmix.core.entity.BaseEntityEntry.getAttributeValue(BaseEntityEntry.java:85) ~[jmix-core-1.1.3.jar:na]
at io.jmix.core.entity.EntityValues.getValue(EntityValues.java:100) ~[jmix-core-1.1.3.jar:na]
at io.jmix.core.impl.serialization.EntitySerializationImpl$EntitySerializer.writeFields(EntitySerializationImpl.java:330) ~[jmix-core-1.1.3.jar:na]
at io.jmix.core.impl.serialization.EntitySerializationImpl$EntitySerializer.serializeEntity(EntitySerializationImpl.java:246) ~[jmix-core-1.1.3.jar:na]
at io.jmix.core.impl.serialization.EntitySerializationImpl$EntitySerializer.writeFields(EntitySerializationImpl.java:354) ~[jmix-core-1.1.3.jar:na]
at io.jmix.core.impl.serialization.EntitySerializationImpl$EntitySerializer.serializeEntity(EntitySerializationImpl.java:246) ~[jmix-core-1.1.3.jar:na]
at io.jmix.core.impl.serialization.EntitySerializationImpl$EntitySerializer.serialize(EntitySerializationImpl.java:219) ~[jmix-core-1.1.3.jar:na]
at io.jmix.core.impl.serialization.EntitySerializationImpl$EntitySerializer.serialize(EntitySerializationImpl.java:187) ~[jmix-core-1.1.3.jar:na]
at com.google.gson.internal.bind.TreeTypeAdapter.write(TreeTypeAdapter.java:81) ~[gson-2.8.9.jar:na]
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:69) ~[gson-2.8.9.jar:na]
at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.write(CollectionTypeAdapterFactory.java:97) ~[gson-2.8.9.jar:na]
at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.write(CollectionTypeAdapterFactory.java:61) ~[gson-2.8.9.jar:na]
at com.google.gson.Gson.toJson(Gson.java:735) ~[gson-2.8.9.jar:na]
at com.google.gson.Gson.toJson(Gson.java:714) ~[gson-2.8.9.jar:na]
at com.google.gson.Gson.toJson(Gson.java:669) ~[gson-2.8.9.jar:na]
at com.google.gson.Gson.toJson(Gson.java:649) ~[gson-2.8.9.jar:na]
at io.jmix.core.impl.serialization.EntitySerializationImpl.toJson(EntitySerializationImpl.java:113) ~[jmix-core-1.1.3.jar:na]
at io.jmix.rest.impl.service.EntitiesControllerManager._loadEntitiesList(EntitiesControllerManager.java:342) ~[jmix-rest-1.1.1.jar:na]
at io.jmix.rest.impl.service.EntitiesControllerManager.loadEntitiesList(EntitiesControllerManager.java:164) ~[jmix-rest-1.1.1.jar:na]
at io.jmix.rest.impl.controller.EntitiesController.loadEntitiesList(EntitiesController.java:69) ~[jmix-rest-1.1.1.jar:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) ~[spring-web-5.3.15.jar:5.3.15]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150) ~[spring-web-5.3.15.jar:5.3.15]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117) ~[spring-webmvc-5.3.15.jar:5.3.15]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895) ~[spring-webmvc-5.3.15.jar:5.3.15]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808) ~[spring-webmvc-5.3.15.jar:5.3.15]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.3.15.jar:5.3.15]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067) ~[spring-webmvc-5.3.15.jar:5.3.15]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963) ~[spring-webmvc-5.3.15.jar:5.3.15]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.3.15.jar:5.3.15]
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) ~[spring-webmvc-5.3.15.jar:5.3.15]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:645) ~[javax.servlet-api-4.0.1.jar:4.0.1]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.3.15.jar:5.3.15]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:750) ~[javax.servlet-api-4.0.1.jar:4.0.1]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227) ~[tomcat-embed-core-9.0.56.jar:9.0.56]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.56.jar:9.0.56]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.56.jar:9.0.56]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.56.jar:9.0.56]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.56.jar:9.0.56]
...