Updated to 6.9.5 , FTS suddenly stopped to work. Last time I tested it with no issues. This happens to me once time ago, and it solved alone the next day.
But this time it remains and through an error:
java.lang.IllegalStateException: Cannot get unfetched attribute [codigoProveedor] from detached object com.company.myerp.entity.Proveedor-e642bc8e-d573-9c26-68a8-a2e35a309991 [detached].
at org.eclipse.persistence.internal.queries.EntityFetchGroup.onUnfetchedAttribute(EntityFetchGroup.java:98)
at com.haulmont.cuba.core.sys.persistence.CubaEntityFetchGroup.onUnfetchedAttribute(CubaEntityFetchGroup.java:74)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.processUnfetchedAttribute(EntityManagerImpl.java:2846)
at com.haulmont.chile.core.model.impl.AbstractInstance._persistence_checkFetched(AbstractInstance.java)
at com.company.myerp.entity.Proveedor._persistence_get_codigoProveedor(Proveedor.java)
at com.company.myerp.entity.Proveedor.getCodigoProveedor(Proveedor.java:38)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.haulmont.chile.core.model.utils.MethodsCache.invokeGetter(MethodsCache.java:72)
at com.haulmont.chile.core.model.impl.AbstractInstance.getValue(AbstractInstance.java:102)
at com.haulmont.cuba.core.entity.BaseGenericIdEntity.getValue(BaseGenericIdEntity.java:139)
at com.haulmont.chile.core.model.utils.InstanceUtils.getInstanceName(InstanceUtils.java:235)
at com.haulmont.chile.core.model.impl.AbstractInstance.getInstanceName(AbstractInstance.java:59)
at com.haulmont.fts.core.app.FtsServiceBean.createEntry(FtsServiceBean.java:215)
at com.haulmont.fts.core.app.FtsServiceBean.makeSearchResult(FtsServiceBean.java:141)
at com.haulmont.fts.core.app.FtsServiceBean.search(FtsServiceBean.java:70)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:85)
at com.haulmont.cuba.core.sys.ServiceInterceptor.aroundInvoke(ServiceInterceptor.java:117)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:629)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:618)
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
at com.sun.proxy.$Proxy291.search(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.haulmont.cuba.core.sys.remoting.LocalServiceInvokerImpl.invoke(LocalServiceInvokerImpl.java:94)
at com.haulmont.cuba.web.sys.remoting.LocalServiceProxy$LocalServiceInvocationHandler.invoke(LocalServiceProxy.java:154)
at com.sun.proxy.$Proxy73.search(Unknown Source)
at com.haulmont.fts.web.ui.results.SearchLauncher.call(SearchLauncher.java:44)
at com.haulmont.fts.web.ui.results.SearchLauncher.call(SearchLauncher.java:22)
at com.haulmont.cuba.gui.WindowManager.createWindowByScreenClass(WindowManager.java:721)
at com.haulmont.cuba.gui.WindowManager.openWindow(WindowManager.java:762)
at com.haulmont.cuba.web.WebWindowManager.openWindow(WebWindowManager.java:158)
at com.haulmont.cuba.gui.components.WindowDelegate.openWindow(WindowDelegate.java:235)
at com.haulmont.cuba.web.gui.WebWindow.openWindow(WebWindow.java:464)
at com.haulmont.cuba.web.gui.components.mainwindow.WebFtsField.openSearchWindow(WebFtsField.java:88)
at com.haulmont.cuba.web.gui.components.mainwindow.WebFtsField$1.handleAction(WebFtsField.java:64)
at com.vaadin.event.ActionManager.handleAction(ActionManager.java:250)
at com.vaadin.event.ActionManager.handleActions(ActionManager.java:228)
at com.haulmont.cuba.web.toolkit.ui.CubaTextField.changeVariables(CubaTextField.java:80)
The stack trace shows that related attribute used in the instance name (@NamePattern) is not fetched for some reason. Could you provide the source code of the entities in question?
Entity Proveedor extends from entity Tercero. Field codigoProveedor is exclusive from Proveedor and is part of @NamePattern, but not on entity Tercero. The search result is about field razonSocial, extended from Tercero,
I tried to reproduce your problem on a test project (attached) but it worked fine. If you can see the difference between the test project and your data model and use case, please let us know.
Thanks for your answer. Some days ago, it worked also fine for me. It’s second time that occurs this issue, as said above, but previously it fixed by itself.
Took a look at you attached example and cant’ see a difference, but there are only 4 fields. I don’t think this is the matter.
I removed codigoProveedor from @NamePattern and it works. Nevertheless, results returns instances of Tercero, not of Proveedor, like your example. Should be the Proveedor entity. This explains why codigoProveedor is unfetched, because it’s not part of the result entity (Tercero). I figure out that something weird happens.
Because i did a trace and saw all getters are from Tercero but codigoProveedor, and because when I removed codigoProveedor from @NamePattern, the returned entity is Tercero and trying to open a no existing Tercero edit screen.
Updated to 6.9.6
I have found that the problem persists. In fact, I have verified that it occurs in all the entities that inherit from another.
Reviewing the trace, I verified that the entity that the FTS selects is the child, but the getters that appears in the list of FTS “getters” in trace, are from the parent, Except those of the @NamePattern. Therefore, it seems that FTS finds the child entity, but it loads the parent’s, and when it tries to execute the getter of the @NamePattern (which belongs to the child) it gives an unfetched error because the loaded entity actually is the parent.
I know all this sounds very messy, but I’m fighting with this several days and can’t see what is wrong in my project.
Perhaps this information throughs a bit of light to find the issue.
P.D. Did a reindexall and a processentirequeue at JMX.
Found a solution wich works for me. Since Tercero is the Parent entity and has no sense to be shown for its own, but only for its childs (Proveedor, Cliente, etc), I removed Tercero from fts.xml file and now it works fine. Only links to entities for Proveedor, Cliente, etc are shown and no exception is thrown.