LazyInitializationException - Seam-managed Entity Manager - 15 min Idle Time
aimee Jun 24, 2010 2:48 PMSeam 2.2.0.GA
JBoss 4.2.3.GA
The session timeout, conversation timeout, and SFSB timeout are set to 180 minutes.
I access the page, which in the code starts a long-running conversation via the Begin annotation. The data on the page is provided by an Entity object that has several collections (FetchType.LAZY) of other Entity objects. When I let the page sit idle for 15 minutes and then try to switch tabs, the app throws a LIE trying to load any collection that is displayed on the tab on which I clicked.
The SFSB backing bean has ScopeType.CONVERSATION and @In private EntityManager entityManager.
I thought that the extended persistence context functionality is implicit for a Seam-managed (or Seam-injected) EntityManager. Debug information shows the conversation is still active, yet the Hibernate session has been closed. How can that happen? Am I missing a setting somewhere? How can I prevent the LIE? The end users frequently leave the application idle for over 15 minutes during the work day.
The conversation that I explicitly started when the page was accessed is still active:
13:32:34,382 INFO [DebugHelperBean] Conversation Context: 13:32:34,382 INFO [DebugHelperBean] name: org.jboss.seam.pageflow.pageflow 13:32:34,382 INFO [DebugHelperBean] name: org.jboss.seam.ui.EntityConverter 13:32:34,382 INFO [DebugHelperBean] name: newRequestManager 13:32:34,382 INFO [DebugHelperBean] name: org.jboss.seam.persistence.persistenceContexts 13:32:34,382 INFO [DebugHelperBean] name: bpmService 13:32:34,382 INFO [DebugHelperBean] name: debugHelper 13:32:34,382 INFO [DebugHelperBean] name: org.jboss.seam.core.conversation 13:32:34,382 INFO [DebugHelperBean] name: org.jboss.seam.international.statusMessages 13:32:34,382 INFO [DebugHelperBean] name: org.jboss.seam.bpm.businessProcess 13:32:34,382 INFO [DebugHelperBean] name: entityManager 13:32:34,382 INFO [DebugHelperBean] CONVERSATION ENTRIES: 13:32:34,382 INFO [DebugHelperBean] Id=29 13:32:34,382 INFO [DebugHelperBean] Description=null 13:32:34,382 INFO [DebugHelperBean] ViewId=/product/createProductRequest.xhtml 13:32:34,382 INFO [DebugHelperBean] Nested=false 13:32:34,382 INFO [DebugHelperBean] Current=true 13:32:34,382 INFO [DebugHelperBean] StartDatetime=Thu Jun 24 12:49:15 CDT 2010 13:32:34,382 INFO [DebugHelperBean] LastDatetime=Thu Jun 24 13:32:32 CDT 2010 13:32:34,382 INFO [DebugHelperBean] Timeout=10800000 13:32:34,382 INFO [DebugHelperBean] ConcurrentRequestTimeout=1000
web.xml:
<session-config> <session-timeout>180</session-timeout><!-- minutes --> </session-config>
components.xml:
<!-- 10800000 milliseconds = 180 minutes -->
<!-- web.xml session timeout is 180 minutes -->
<core:manager concurrent-request-timeout="1000"
conversation-timeout="10800000"
conversation-id-parameter="cid"
parent-conversation-id-parameter="pid" />
<!-- Persistence -->
<persistence:entity-manager-factory
name="entityManagerFactory"
persistence-unit-name="TsseJ" />
<persistence:managed-persistence-context
auto-create="true"
entity-manager-factory="#{entityManagerFactory}"
name="entityManager" />jboss-4.2.3.GA/server/default/conf/standardjboss.xml:
<container-configuration> <container-name>Standard Stateful SessionBean</container-name> ... <!-- see Seam 2.2.0.GA docs 30.8 Configuring SFSB and Session Timeouts in JBoss AS --> <!-- SFSB timeout in seconds --> <!-- seam session timeout and conversation timeout is 180 minutes --> <max-bean-life>10800</max-bean-life> ... </container-configuration>
The backing bean:
@Name("newRequestManager")
@Scope(ScopeType.CONVERSATION)
@Stateful
@Restrict("#{identity.loggedIn}")
public class NewRequestManagerBean implements NewRequestManager, TsseConstants,
Serializable {