3 Replies Latest reply on Aug 29, 2007 3:28 PM by wquraishi

    New LazyInitializationException from beta1 to CR2

    rdewell

      Upgrading from beta1 to CR2. Continuing to use SeamExtendedManagedPhaseListener as always. I have a Session scoped component that holds an entity reference. However, I'm now receiving a LazyInitializationException when accessing that entity on the "next" request:

      org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.x.site.SiteOwner.siteList, no session or session was closed
       at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:358)
       at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:350)
       at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:343)
       at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
       at org.hibernate.collection.PersistentBag.iterator(PersistentBag.java:246)
       at com.sun.facelets.tag.jstl.core.ForEachHandler.toIterator(ForEachHandler.java:254)
      


      I never received LazyInitializationException's in beta 1 and am wondering what I might need to change to avoid them again.

      Thanks,

      Ryan

        • 1. Re: New LazyInitializationException from beta1 to CR2
          gavin.king

          Seam-managed PCs let you avoid LIE's while inside the conversation scope.

          The *do not* solve this problem for the whole session scope.

          • 2. Re: New LazyInitializationException from beta1 to CR2
            rdewell

            Thanks. I converted those beans accordingly. No more LazyInitException.

            Back to this error now, though:

            11:02:43,668 ERROR [STDERR] org.hibernate.TransactionException: could not register synchronization w
            ith JTA TransactionManager
             at org.hibernate.jdbc.JDBCContext.registerSynchronizationIfPossible(JDBCContext.java:174)
             at org.hibernate.impl.SessionImpl.checkTransactionSynchStatus(SessionImpl.java:1824)
            


            As I make progress in other areas, I eventually just end up with this error again. Is anyone else getting this? I don't even know where to start looking to solve this one.

            Ryan

            • 3. Re: New LazyInitializationException from beta1 to CR2
              wquraishi

              One thing I discovered is if you override the toString() method and output the relationships, it'll force the container to load the relationship related fields. I'm thinking it accomplishes the same thing as fetchtype.eager but i've had more luck with this. Plus it works dual fold since I use the toString() method in conjunction with facesMessages to display what the object coming back is.