I have a StandardLookup screen with a Create button. It opens the StandardEditor screen. In that screen, I have an onBeforeShow subscription. It executes the following lines:
It gives me the following error on the if statement:
IllegalStateException: Cannot get unfetched attribute [rtype] from detached object com.paslists.rade.entity.Customer-177 [detached].
with this stacktrace:
java.lang.IllegalStateException: Cannot get unfetched attribute [rtype] from detached object com.paslists.rade.entity.Customer-177 [detached].
at org.eclipse.persistence.internal.queries.EntityFetchGroup.onUnfetchedAttribute(EntityFetchGroup.java:100)
at com.haulmont.cuba.core.sys.persistence.CubaEntityFetchGroup.onUnfetchedAttribute(CubaEntityFetchGroup.java:74)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.processUnfetchedAttribute(EntityManagerImpl.java:2998)
at com.haulmont.chile.core.model.impl.AbstractInstance._persistence_checkFetched(AbstractInstance.java)
at com.paslists.rade.entity.Customer._persistence_get_rtype(Customer.java)
at com.paslists.rade.entity.Customer.getRtype(Customer.java:185)
at com.paslists.rade.web.customer.CustomerEdit.onBeforeShow(CustomerEdit.java:167)
at com.haulmont.bali.events.EventHub.publish(EventHub.java:170)
at com.haulmont.cuba.gui.screen.Screen.fireEvent(Screen.java:128)
at com.haulmont.cuba.gui.screen.UiControllerUtils.fireEvent(UiControllerUtils.java:60)
at com.haulmont.cuba.web.sys.WebScreens.show(WebScreens.java:444)
at com.haulmont.cuba.gui.screen.Screen.show(Screen.java:309)
at com.haulmont.cuba.gui.actions.list.CreateAction.execute(CreateAction.java:345)
at com.haulmont.cuba.gui.actions.list.CreateAction.actionPerform(CreateAction.java:287)
at com.haulmont.cuba.web.gui.components.WebButton.buttonClicked(WebButton.java:67)
at com.haulmont.cuba.web.widgets.CubaButton.fireClick(CubaButton.java:76)
at com.vaadin.ui.Button$1.click(Button.java:57)
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.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:153)
at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:115)
at com.vaadin.server.communication.ServerRpcHandler.handleInvocation(ServerRpcHandler.java:431)
at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:396)
at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:260)
at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:82)
at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:40)
at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1578)
at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:425)
at com.haulmont.cuba.web.sys.CubaApplicationServlet.serviceAppRequest(CubaApplicationServlet.java:329)
at com.haulmont.cuba.web.sys.CubaApplicationServlet.service(CubaApplicationServlet.java:215)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:108)
at org.springframework.web.filter.CompositeFilter.doFilter(CompositeFilter.java:74)
at com.haulmont.cuba.web.sys.CubaHttpFilter.doFilter(CubaHttpFilter.java:93)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:526)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:678)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:861)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1579)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
You always deal with detached entities in screens.
Cannot get unfetched attribute exception happens only if you don’t have the attribute in the view. Please double-check customer-edit-view and ensure that this attribute is included in this view. The screenshot that you have provided doesn’t show the view’s definition. Could you show the view definition, please?
It would be nice if you could provide a minimal example that shows the issue, so we could reproduce it here. It is quite hard to diagnose the problem without seeing a full picture.
As I understand it, “_base” = “_local” + “_minimal” on all related Entities. In my original post, I showed you a screen shot of the rtype field in the Customer entity.
So, _base should include rtype, shouldn’t it?
As for an example, I am not able to duplicate the problem. It has something to do with my application as it stands, so creating a test case would not help.
That’s what I need help finding. What is wrong in my app? Let me know what else I can post to help figure it out.
I’ve often found that building a sample app to reproduce a problem to be helpful. Most of the helpers here need it, so they can see the problem “live” and work out a solution.
It’s usually not too hard to build one up. 5-10-15 minutes tops.
Here’s a question: When I set up standard default Browse and Editor screens, what view is attached to the entity created by the Create button in the standard action? It seems like it is “_minimal” on my object. Shouldn’t it be the view I defined in my Browse descriptor?
I am seeing the FetchGroup for the created object to be just the items in the Instance Name. That seems to indicate to the system that the other fields are not there. But the object is New (before it is Detached in the screen).
How does the system identify a missing attribute and put up that error message?
There are times when I execute this screen with a requested customer in mind. I call setCustomerToLoad with the entity. In the BeforeShow event, if the requested customer has been provided, I set the parameter in the condition and do a load. If no entity has been provided, I remove the parameter and use the entity provided to the screen by the framework.
Could this be throwing things off? What is the correct way to handle this?