2 Replies Latest reply on Oct 6, 2008 1:55 PM by beligum.b.beligum.org

    Session context in @Create method

    beligum.b.beligum.org

      Hi all,


      I'm having some Lazy-Load Exceptions in a @Create-annotated method.
      The collection is a many-to-many collection with a jointable.


      When trying to access the collection, I get the usual LIE-error:


      org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: be.beligum.huureenstudent.entities.Person.employers, no session or session was closed



      Is it possible the session isn't really initialized in the @Create method of a session-scoped SFSB, or am I missing something? For clarity, I'm not including the full stacktrace, but feel free to yell at me for leaving it out.


      thx in advance,


      b.

        • 1. Re: Session context in @Create method
          beligum.b.beligum.org

          More info regarding this issue:


          The collection is part of a session-scoped entity bean.
          I tried to do a entityManager.refresh(myEntityBean) in the @Create method, and I'm getting a Entity not managed exception. The bean get's initialized in the Authenticator bean ofter login, and is outjected with a Session scope using annotations:


          @Out(required=true, scope=SESSION)
          private Principal currentPrincipal;



          I also tried the different approach as in the examples:


          Contexts.getSessionContext().set("authenticatedMember", member);



          No luck there either.


          Btw, I'm using Seam 2.0.2.SP1 on JBoss 4.2.0

          • 2. Re: Session context in @Create method
            beligum.b.beligum.org

            Fixed.
            For future reference:
            Forgot to add


            <action execute="#{identity.login}" if="#{validation.succeeded}"/>



            to pages.xml.