6 Replies Latest reply on Sep 13, 2007 10:56 AM by asavitsky

    LazyInitializationExceptions are staying

    l j Newbie

      I use the following combination of tools:
      Seam 1.2 GA
      Apache MyFaces
      hibernate-commons-annotations 3.3.0.ga
      com.sun.facelets 1.1.12
      org.ajax4jsf 1.1.1
      org.richfaces 3.0.1
      jboss-ejb3-all 3.0.0
      hibernate 3.0.0

      I want to make use of Seam-managed persistence context with JPA; the problem I get is that lazy loading (FetchType.LAZY) isn't working ; if I use FetchType.EAGER everything works correctly.

      I get the following error:
      org.hibernate.LazyInitializationException: failed to lazily intialize a collection of role: .....

      I followed the tutorial within the SEAM tutorial

      I have the following configuration of a project including 2 subprojects, which are packed in seperate jars.

      Jars/wars in total ear project:
      1. JAR ejb project containing the domain objects, service layer (stateless ejb3 beans) and controller layer (statefull ejb3 beans); in this jar the persistence.xml is located in the META-INF directory
      2. JAR commons project containing helper classes (in this jar the entitymanager is injected using
      private EntityManager entityManager
      3. WAR web project

      Overview of configuration files:

      persistence.xml (located in META-INF directory van ejb jar)
      <?xml version="1.0" encoding="UTF-8"?>
      <persistence xmlns="http://java.sun.com/xml/ns/persistence"
      xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
      <persistence-unit name="atinvestorDb">

      <!-- These are the default for JBoss EJB3, but not for HEM: -->

      <!-- Put the EntityManagerFactory into JNDI so we can use it manually in tests -->

      <!--property name="jboss.entity.manager.jndi.name" value="java:/atinvestorEntityManager"/-->


      components.xml (located in WEB-INF of web WAR)
      <core:managed-persistence-context name="entityManager"
      persistence-unit-jndi-name="java:/atinvestorEntityManagerFactory" />

      faces-config.xml (located in WEB-INF of web WAR)



      Can someon help me why I don't get lazy loading to work with this configuration.

      - Can it be that the problem is in the fact that the injection of the EntityManager is within another JAR then where the persistency unit residence (and therefore the persistence.xml file is located) ?

      Thanks beforehand.