5 Replies Latest reply on Jan 24, 2008 8:39 AM by limousyf

    Conversation Beans and Session scoped beans resulting in "Co

    limousyf

      Hello,

      I just had the "Could not find stateful Bean" error in my application.
      After searching in the forum, I finally understand that a bean with a wider scope (Session) kept a reference of the stateful bean that cannot be find by other sessions.

      Here is some snipplets of my code:


      The session-scoped bean

      @Scope(ScopeType.SESSION)
      @Name("gestionaffichage")
      public class GestionAffichageBean implements GestionAffichage
      



      The stateful bean

      @Stateful
      @Scope(ScopeType.CONVERSATION)
      @Name("activitesByCollaborateurCrossData")
      public class activitesByCollaborateurCrossDataBean implements activitesByCollaborateurCrossData
      
      
      bla bla bla ...
      
      
       @In
       public GestionAffichage gestionaffichage;
      
      
      yada yada ...
      
      
       public void setRealise()
       {
       this.realise = true;
       this.debut();
       gestionaffichage.afficherMenuActiviteParCollaborateur();
       }
      



      Since I add the "gestionaffichage" calls in my stateful bean, "Could not find stateful Bean" errors appeared.
      I temporary moved the scope of "gestionaffichage" to APPLICATION to avoid problems but it's not supposed to be shared between clients.

      My question is: why does this error happen ?

      I mean, I don't have a reference of my stateful bean in my session-scoped bean; I have the exact opposite: an injection of my session-scoped bean in the conversation.

      So I don't get how the error is supposed to happen.
      Can't I inject a "wider" scoped bean in my conversation ?
      I certainly missed something here but I don't know what ...

      Regards

        • 1. Re: Conversation Beans and Session scoped beans resulting in

          just some thoughts:

          • are you sure, the GestionAffichage bean has already been created and exists in the session scope?
          • maybe the GestionAffichage cannot be created (for any reason) and thus the activitesByCollaborateurCrossData cannot be created.
          • it's also strange, that the activitesByCollaborateurCrossData interface starts with lowercase (and also the bean class) and is the same as the Seam component name
            note: I am a newbie myself and I haven't seen the errormessage "Could not find stateful Bean" yet


          • 2. Re: Conversation Beans and Session scoped beans resulting in
            limousyf

            Well I guess the gestionAffichageBean is created; I think I could add the "create=true".
            But, as I deference the bean

            gestionaffichage.afficherMenuActiviteParCollaborateur()
            


            I would have a NPE if it wasn't created.

            The names are clearly incorrect (intern work :) ) but I don't think that it's a problem here.

            • 3. Re: Conversation Beans and Session scoped beans resulting in
              limousyf

              Just a question.
              The session-scoped bean was stateful at the beginning, which was clearly a mistake (man, I love interns !).

              Is it possible that the stateful session-scoped bean is destroyed at conversation timeout ?
              Or when another conversation using this bean stops ? (maybe it's moved from session scope to conversation scope, then destroyed at conversation ending).

              I thought that because I saw

              10:06:26,171 INFO [STDOUT] Mort du Bean GestionConfigurationBean Scope = Application
              


              in my log, which is the message lauched when a bean is destroyed.

              In this case, it's a stateful application-scoped bean (please god save me from internicide).
              It's clearly another mistake here, but the fact is that my application-scoped bean is destroyed !

              I don't know if it's a bug or a feature ...

              Regards

              • 4. Re: Conversation Beans and Session scoped beans resulting in
                pmuir

                Post the exception and stack trace.

                The session-scoped bean was stateful at the beginning, which was clearly a mistake (man, I love interns !).


                Why is making a session scoped bean @Stateful a mistake?

                Is it possible that the stateful session-scoped bean is destroyed at conversation timeout ?


                No

                • 5. Re: Conversation Beans and Session scoped beans resulting in
                  limousyf

                  Well it was a clear mistake in that case: the conversation was opened at the bean creation and never closed.

                  Well, I'll try to reproduce the bug and post the stacktrace