Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Vaadin UI session gets closed prematurely
in my current project, that is based on Vaadin 7.6.2, I get an error that I simply don't find an explanaition for in my code. In this application, I open up a bunch of EntityManagers for a UI session and then close them when the session is detatched (when UI.detatch() is called). Now my problem is that my log clearly states that the session is detatched and then used again. AFAIK this should not happen, right?
Here is an excerp from the log file:
*** || 29.02.2016 09:59:32:504 | SESSION BEC3759B529AC42AA7FFE62314633979 | USER a******.i**** | de.darkblue.bagheera.db.EntityManagerBeanFactory.closeAll() || Closed 3 entity managers for session a******.i**** *** || 29.02.2016 09:59:32:504 | SESSION BEC3759B529AC42AA7FFE62314633979 | USER a******.i**** | de.darkblue.bagheera.BagheeraUI.detach() || Session de.darkblue.bagheera.BagheeraUI@1c5c5ab2 was detatched. [...] !!!! || 29.02.2016 10:00:21:159 | SESSION BEC3759B529AC42AA7FFE62314633979 | USER a******.i**** | com.vaadin.server.DefaultErrorHandler.doDefault() || caused by: || java.lang.IllegalStateException: Attempting to execute an operation on a closed EntityManager. || at org.eclipse.persistence.internal.jpa.EntityManagerImpl.verifyOpenWithSetRollbackOnly(EntityManagerImpl.java:1934) || at org.eclipse.persistence.internal.jpa.EntityManagerImpl.getCriteriaBuilder(EntityManagerImpl.java:2569) || at de.darkblue.bagheera.ui.tab.EditActivityReportTab.isOverlappingEntry(EditActivityReportTab.java:383) || [...]
You can see that the session BEC3759B529AC42AA7FFE62314633979 was closed at 09:59:32:504 but then reused nearly one minute later. I was under the impression that when UI.detatch() was called (as in log line 2), the UI instance was not used anymore, becuase the session expired (due to three mission heartbeats)? I get the feeling that I have the wrong idea about the lifecycle of a Vaadin UI session. It would be nice if someone could shed some light on this topic. :/
If anyone is having similar difficulties - the solution is here: http://stackoverflow.com/questions/35726857/vaadin-7-ui-session-gets-closed-prematurely