IllegalStateException: Cannot get unfetched attribute [imageFile] from detached object

I am new to CUBA-platform.
I got this error when trying to load and display an imageFile. What might be the issue here?
Thanks

IllegalStateException: Cannot get unfetched attribute [imageFile] from detached object com.company.sales.entity.Customer-9bf325e3-1870-c7dc-d220-925165005717 [detached].

===========================================

java.lang.IllegalStateException: Cannot get unfetched attribute [imageFile] from detached object com.company.sales.entity.Customer-9bf325e3-1870-c7dc-d220-925165005717 [detached].
	at org.eclipse.persistence.internal.queries.EntityFetchGroup.onUnfetchedAttribute(EntityFetchGroup.java:98)
	at com.haulmont.cuba.core.sys.persistence.CubaEntityFetchGroup.onUnfetchedAttribute(CubaEntityFetchGroup.java:48)
	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.sales.entity.Customer._persistence_get_imageFile(Customer.java)
	at com.company.sales.entity.Customer.getImageFile(Customer.java:51)
	at com.company.sales.web.customer.CustomerEdit.displayImage(CustomerEdit.java:137)
	at com.company.sales.web.customer.CustomerEdit.postInit(CustomerEdit.java:116)
	at com.haulmont.cuba.gui.components.AbstractEditor.setItem(AbstractEditor.java:71)
	at com.haulmont.cuba.gui.WindowManager.openEditor(WindowManager.java:715)
	at com.haulmont.cuba.web.WebWindowManager.openEditor(WebWindowManager.java:143)
	at com.haulmont.cuba.gui.components.WindowDelegate.openEditor(WindowDelegate.java:250)
	at com.haulmont.cuba.web.gui.WebWindow.openEditor(WebWindow.java:466)
	at com.haulmont.cuba.gui.components.actions.EditAction.internalOpenEditor(EditAction.java:188)
	at com.haulmont.cuba.gui.components.actions.EditAction.actionPerform(EditAction.java:181)
	at com.haulmont.cuba.web.gui.components.WebAbstractTable.handleClickAction(WebAbstractTable.java:672)
	at com.haulmont.cuba.web.gui.components.WebAbstractTable.lambda$initComponent$4fd149ee$1(WebAbstractTable.java:564)
	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.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:508)
	at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:198)
	at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:161)
	at com.vaadin.server.AbstractClientConnector.fireEvent(AbstractClientConnector.java:1030)
	at com.vaadin.ui.Table.handleClickEvent(Table.java:3219)
	at com.vaadin.ui.Table.changeVariables(Table.java:2995)
	at com.haulmont.cuba.web.toolkit.ui.CubaTable.changeVariables(CubaTable.java:217)
	at com.vaadin.server.communication.ServerRpcHandler.changeVariables(ServerRpcHandler.java:609)
	at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:428)
	at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:274)
	at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:79)
	at com.haulmont.cuba.web.sys.CubaVaadinServletService$CubaUidlRequestHandler.lambda$synchronizedHandleRequest$92(CubaVaadinServletService.java:307)
	at com.haulmont.cuba.web.sys.CubaVaadinServletService.withUserSession(CubaVaadinServletService.java:189)
	at com.haulmont.cuba.web.sys.CubaVaadinServletService$CubaUidlRequestHandler.synchronizedHandleRequest(CubaVaadinServletService.java:307)
	at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:41)
	at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1409)
	at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:369)
	at com.haulmont.cuba.web.sys.CubaApplicationServlet.serviceAppRequest(CubaApplicationServlet.java:254)
	at com.haulmont.cuba.web.sys.CubaApplicationServlet.service(CubaApplicationServlet.java:163)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
	at com.haulmont.cuba.web.sys.CubaHttpFilter.handleNotFiltered(CubaHttpFilter.java:108)
	at com.haulmont.cuba.web.sys.CubaHttpFilter.doFilter(CubaHttpFilter.java:95)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1099)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)

Ensure that you use a proper view in the Customer editor. The view should contain the imageFile attribute.

2 Likes

Thanks. It’s solved.

Hi Konstantin Krivopustov,
I am facing the same issue after setting the view. My requirement is, my child entity class contained parent object and using parent object i need to get the parent entity attribute. Ex. childObject().parentObject().someParentAttribute(). But still I m getting the same issue.
IllegalStateException: Cannot get unfetched attribute [parentObject] from detached object com.demo…entity.ChildEntity-b0e5ef68-07d5-d1d2-b8f2-07b956720966 [detached].
My view Description is given below.

<view class="com.demo.entity.ChildEntity" 
          extends="_local" 
          name="ChildEntityVIEW-view"> 
                <property  
                  name="someParentAttribute" 
                  view="_local"/> 
    </view> 

kindly help on the same.

Hi
the view does not load the associated master entity.

If you have entities like the classic Order and OrderDetail (master/detail), your Order entity should contain an details or rows ASSOCIATION attribute (ONE-TO-MANY) pointing to related OrderDetail entities. Then Studio will ask to create corresponding MANY-TO-ONE association attribute to OrderDetail, that will be named order.

To be able to load the master entity from its detail (that is the order attribute for an OrderDetail) you must include it in the view, and you’ll be able to use it in your screen.

Paolo