11 Replies Latest reply on Feb 28, 2008 9:59 PM by Srinivasan N. Raguraman

    elements from a list field in a statefull ejb seam bean becomes null during a conversation

    Dragos D Newbie

      Hi, I have a statefull ejb seam bean which contains a field of type List. During a conversation a new page is displayed and the List is filled with some entity beans and displayed
      with ui:repeat tag. The problem arrives when I have to display another page in the same conversation because somehow the list elements becomes null.


      Does someone encountered this kind of problem?


      Thanks

        • 1. Re: elements from a list field in a statefull ejb seam bean becomes null during a conversation
          Keith Naas Novice

          Are you sure that the other page is in the same conversation.


          Try putting a Conversation List on both pages just to see if the conversation is different.

          • 2. Re: elements from a list field in a statefull ejb seam bean becomes null during a conversation
            Ajay Gupta Newbie

            Check cid parameter in the URL for the 2nd page in case you are including it in the URL. From the description of the problem above, it sounds like your second page is opening in a new conversation than from the first page.

            • 3. Re: elements from a list field in a statefull ejb seam bean becomes null during a conversation
              Dragos D Newbie

              I checked out the seam debug page and the conversation id is the same. But even in the case that a new conversation begins I don't understand why the list elements should become null and not the list itself!


              Any other thoughts?

              • 5. Re: elements from a list field in a statefull ejb seam bean becomes null during a conversation
                Keith Naas Novice

                oops....implement not extend...



                Keith Naas wrote on Feb 27, 2008 08:56 PM:


                Do the items being placed in the list extend Serializable?

                • 6. Re: elements from a list field in a statefull ejb seam bean becomes null during a conversation
                  Dragos D Newbie

                  Yes, as I said the items in the list are entity beans that implements Serializable. I also suspected this problem but no succes. The session bean is not passivated during the conversation so no serialisation occurs. And suppose that an unsuccessfull deserialisation occurs this should throws a detectable exception isn't it? My log didn't show any exception

                  • 8. Re: elements from a list field in a statefull ejb seam bean becomes null during a conversation
                    Dragos D Newbie

                    Sure



                    @Stateful
                    @Name("catalogCommoditiesAction")
                    public class CatalogCommoditiesActionBean implements CatalogCommoditiesAction, Serializable {
                    
                         @Logger
                         private Log logger;
                    
                         @In
                         private Catalog catalog;
                    
                         @In
                         private EntityManager entityManager;
                    
                         private List<StdProductOrService> selectionPath;
                    ...
                    



                    selectionPath is the List. In the same bean I put a method that add elements in it:



                         public void selectSposFromTable() {
                              loadSrcSposDataModel(srcSpos.getCode());
                              if (selectionPath == null) {
                                   selectionPath = new ArrayList<StdProductOrService>();
                              }
                              selectionPath.add(srcSpos);
                         }
                    


                    The list contains readonly entity beans



                    @Entity
                    @org.hibernate.annotations.Entity(mutable = false)
                    @Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
                    @Table(name = "STD_PRODUCT_OR_SERVICE")
                    @NamedQuery(name = "getAllStdProductOrServiceCodes", query = "SELECT spos.code FROM StdProductOrService spos")
                    public class StdProductOrService implements Serializable {
                         static final long serialVersionUID = 0;
                    
                         String code;
                         String name;
                         boolean leaf;
                    
                         StdProductOrService parent;
                         List<StdProductOrService> children;
                         private boolean selected;
                    
                         public StdProductOrService() {
                         };
                    
                         @Column(name = "CODE")
                         @Id
                         public String getCode() {
                              return code;
                         }
                    ...
                    



                    debug seam before main screen:




                    Conversations
                    conversation id      activity      description      view id      
                    12      5:45:33 AM -5:46:29 AM           /secured/sell/catalog/catalog.xhtml      Select conversation context
                    + -  Component (None selected)
                    Select a component from one of the contexts below
                    + -  Conversation Context (12)
                    catalog
                    catalogAction
                    catalogCommoditiesAction
                    catalogCommoditiesAction.dstSposDataModel
                    catalogTabsBean
                    entityManager
                    org.jboss.seam.core.conversation
                    org.jboss.seam.faces.facesMessages
                    org.jboss.seam.persistence.persistenceContexts
                    


                    Enter the screen, dispplay successfull:



                    Conversations
                    conversation id      activity      description      view id      
                    12      5:45:33 AM -5:49:08 AM           /secured/sell/catalog/catalog_commodities.xhtml      Select conversation context
                    + -  Component (None selected)
                    Select a component from one of the contexts below
                    + -  Conversation Context (12)
                    catalog
                    catalogAction
                    catalogCommoditiesAction
                    catalogCommoditiesAction.dstSposDataModel
                    catalogCommoditiesAction.selectionPath
                    catalogCommoditiesAction.srcSpos
                    catalogCommoditiesAction.srcSposDataModel
                    catalogTabsBean
                    entityManager
                    org.jboss.seam.core.conversation
                    org.jboss.seam.faces.facesMessages
                    org.jboss.seam.persistence.persistenceContexts



                    selectionPath content as displayed by debug page(ok):


                    Conversations
                    conversation id      activity      description      view id      
                    12      5:45:33 AM -5:50:19 AM           /debug.xhtml      Select conversation context
                    + -  Component (catalogCommoditiesAction.selectionPath)
                    0      com.systemaplus.b2b.entity.StdProductOrService@eeed5341
                    + -  Conversation Context (12) 



                    Things goes wrong:



                    onversations
                    conversation id      activity      description      view id      
                    12      5:45:33 AM -5:52:06 AM           /debug.xhtml      Select conversation context
                    + -  Component (catalogCommoditiesAction.selectionPath)
                    0      
                    + -  Conversation Context (12)
                    catalog
                    catalogAction
                    catalogCommoditiesAction
                    catalogCommoditiesAction.dstSposDataModel
                    catalogCommoditiesAction.selectionPath
                    catalogCommoditiesAction.srcSpos
                    catalogCommoditiesAction.srcSposDataModel
                    catalogLineDataModel
                    catalogLineDataModel.wrappedData
                    catalogTabsBean
                    entityManager
                    org.jboss.seam.core.conversation
                    org.jboss.seam.faces.facesMessages
                    org.jboss.seam.persistence.persistenceContexts



                    Notice that the selectionPath is displayed somehow different than first time (contains a null value) despite that is actually listed in the same context id (12).


                    Help, I'm stuck

                    • 9. Re: elements from a list field in a statefull ejb seam bean becomes null during a conversation
                      Srinivasan N. Raguraman Newbie

                      Given the conversation is long running one, and catalogCommoditiesAction is a @Stateful (i.e. conversation scope in seam) this shld work.
                      Try explicitly mentioning the seam scope for the component catalogCommoditiesAction (CONVERSATION/SESSION), and also make sure ejb is not removed.

                      • 10. Re: elements from a list field in a statefull ejb seam bean becomes null during a conversation
                        Dragos D Newbie

                        I tested with SESSION context and it's OK. When I reversed to CONVERSATION (explicit) the wrong behavior appears again.


                        One more important thing here:


                        I use richfaces tabcontrol to change pages. If I don't change the tabs it's ok. don't know how tab control integrates with seam conversations (does it?)


                        • 11. Re: elements from a list field in a statefull ejb seam bean becomes null during a conversation
                          Srinivasan N. Raguraman Newbie

                          Where in code are you promoting the conversation to a long running one?


                          Since the entity disappears only on using conversation scope, the conversation is basically ending before it goes to the next page.