0 Replies Latest reply on Apr 18, 2009 5:34 PM by germandev.net-seam.wje-online.de

    Problem performing action on stateful session bean

    germandev.net-seam.wje-online.de

      Hi!


      I am currently working on a little web shop application using Seam 2.1.


      I created an entity bean 'Artikel' and the following Session Bean (I didn't post the interface but created it as well):


      @Stateful
      @Scope(ScopeType.SESSION)
      @Name("artikel")
      public class ArtikelSucheBean implements ArtikelSuche, Serializable
      {
           private static final long serialVersionUID = 1L;
      
           @Remove
           public void remove(){}
      
           @Destroy
           public void destroy(){}
      
           @PersistenceContext
           private EntityManager em;
      
           @DataModel
           private List<Artikel> lstArtikel;
      
           @SuppressWarnings("unchecked")
           private void updateResults()
           {
                this.lstArtikel = em.createQuery("select a from Artikel a").getResultList();
           }
      
           @Create
           public void setUp()
           {
                updateResults();
           }
      
           public List<Artikel> getLstArtikel() {
                return lstArtikel;
           }
      
           public void setLstArtikel(List<Artikel> lstArtikel) {
                this.lstArtikel = lstArtikel;
           }
      }
      




      while 'ArtikelSuche' should list the articles.


      This is the .xhtml I am working on


      <h:form>
      <rich:scrollableDataTable value="#{artikel.lstArtikel}" var="_art"
                  rendered="#{not empty artikel.lstArtikel}">
                     <rich:column id="colName">
                          <f:facet name="header">Produktname</f:facet>
                          <h:outputText value="#{_art.strName}" />
                     </rich:column>
                     <rich:column id="colActions" sortable="false">
                          <f:facet name="header">&#160;</f:facet>
                          <h:inputText value="#{warenkorb.intAnzahl}"  maxlength="3" required="true" size="3">
                          </h:inputText>
                          &#160;&#160;
                          <h:commandButton action="#{warenkorb.kaufen(_art)}" value="Korb"/>
                     </rich:column>
                </rich:scrollableDataTable>
      </h:form>
      



      I now have two problems:


      (1) When opening the .xhtml page for the first time, I get the following error:


      javax.faces.FacesException: javax.el.ELException: /shop.xhtml @17,89 rendered="#{empty artikel.lstArtikel}": Error reading 'lstArtikel' on type org.javassist.tmp.java.lang.Object_$$_javassist_1
      ..
      Caused by: javax.el.ELException: /shop.xhtml @17,89 rendered="#{empty artikel.lstArtikel}": Error reading 'lstArtikel' on type org.javassist.tmp.java.lang.Object_$$_javassist_1
           at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:76)
           at javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:370)
           ... 59 more
      Caused by: javax.ejb.NoSuchEJBException: Could not find stateful bean: 5c4o240-mw6blu-ftoghz1u-1-ftogjm5u-e
           at org.jboss.ejb3.cache.simple.SimpleStatefulCache.get(SimpleStatefulCache.java:390)
      ..
      


      After pressing F5 to reload the page is shown correctly. I already added  @Create (see above) to initialize the list before the page is loaded but it hasn't changed anything. What is my mistake?


      (2) When trying to change to sort order of the grid, or doing anything else that produces a postback the following error is shown:



      Exception during request processing: 
      Caused by javax.servlet.ServletException with message: "3" 
      Caused by java.lang.ArrayIndexOutOfBoundsException with message: "3"
      



      I don't know why there is an ArrayIndoexOutOfBoundsException, may that be related to my first question?
      I don't know why there is an ArrayIndoexOutOfBoundsException, may that be related to my first question?


      Thank you in advance!