1 Reply Latest reply on Sep 27, 2007 9:17 AM by jacob.orshalick

    Exception: No session or session closed

    damatrix

      I'm using JBoss 4.2.1.GA and Seam 2.0 CR1. I have an SFSB as follows

       */
      @Stateful
      @Name(value = "fairListing")
      @Scope(ScopeType.SESSION)
      public class FairListBean implements FairListLocal {
      
       @In
       EntityManager entityManager;
      
       @In
       FacesMessages facesMessages;
      
       @DataModel
       private List<FairDTO> fairs;
      
       @DataModelSelection("fairs")
       private FairDTO fair;
      
       @Factory("fairs")
       public void list(){
       fairs = new FairQM(entityManager).findAll();
       }
      
       public void showDetails(){
       this.fair = entityManager.merge(fair);
       }
      }
      


      I'm using this to manage a Master-Detail page showing a dataTable of fairs. when a fair is selected, the showDetails() action is called and the details of a fair are shown below the dataTable using an <a:outputPanel>.

      I read that using the ManagedPersistenceContext configured in components.xml and injected in your code does not throw LazyInitializationException (hope i got that right :-) ). I was quite surprised to find this exception being thrown.

      Can anyone point out what i'm doing wrong?


        • 1. Re: Exception: No session or session closed

           

          "damatrix" wrote:
          I read that using the ManagedPersistenceContext configured in components.xml and injected in your code does not throw LazyInitializationException (hope i got that right :-) ). I was quite surprised to find this exception being thrown.


          This is correct. The first issue I notice that you are not outjecting the "fair" DataModelSelection. You will have to explicitly outject a DataModelSelection to make it available to the view. While fair is set in the FairListBean, it will not be directly available in the context.

          Another question, why are you using SESSION scope? An SMPC is intended for use within a conversation (and conversations are almost always recommended when using Seam over dropping things in the session).