10 Replies Latest reply on Mar 1, 2008 11:15 AM by Pete Muir

    Bug in Seam 2.0.1 ? Please help.

    Toni Beckman Novice

      Hi,


      I'm trying to move our webapplication to Seam 2.0.1 - without luck. It has been working well under Seam 1.2.1 for abour a year.


      To nail down the issue I have written a very small and simple test application. It only consists of a SFSB, an Entity Bean and a JSP page.


      Could somebody from the JBoss Team have a look at it? I suspect a bug, because it's a very simple szenario, which should work.


      You can download the ready-to-deploy exploded ear from http://213.239.213.83/calc.ear.tgz and extract it straight into your deploy directory.


      Then call http://localhost:8080/calc/test.seam


      You will get an EJBTransactionRolledbackException, which originates from a NullPointerException in the ManagedEntityIdentityInterceptor


      The test application is so simple that I really don't know how to further simplify it. So please, if somebody can have look at it.


      I'm running on sarge (kernel 2.6.23.1), suns jdk 1.5.0(14) and JBoss 4.2.2 GA


      Here are the sources (the rest can be found in the exploded ear):


      Entity Bean


      package de.test.calc.model;
      
      import org.jboss.seam.annotations.Name;
      
      import javax.persistence.Entity;
      import javax.persistence.GeneratedValue;
      import javax.persistence.GenerationType;
      import javax.persistence.Id;
      import javax.persistence.Lob;
      import java.io.Serializable;
      
      
      @Entity
      @Name("testEntity")
      
      public class TestEntity implements Serializable
      {
        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        long id;
        
        @Lob
        String subject;
        @Lob
        String body;
      
        public long getId()
        {
          return id;
        }
      
        public void setId(long id)
        {
          this.id = id;
        }
      
        public String getSubject()
        {
          return subject;
        }
      
        public void setSubject(String subject)
        {
          this.subject = subject;
        }
      
        public String getBody()
        {
          return body;
        }
      
        public void setBody(String body)
        {
          this.body = body;
        }
      
      
        public boolean equals(Object o)
        {
          if (this == o) return true;
          if (o == null || getClass() != o.getClass()) return false;
      
          TestEntity that = (TestEntity) o;
      
          if (id != that.id) return false;
      
          return true;
        }
      
      
        public int hashCode()
        {
          return (int) (id ^ (id >>> 32));
        }
      
      }
      



      SFSB


      package de.test.calc.workflow;
      
      import org.jboss.seam.annotations.Destroy;
      import org.jboss.seam.annotations.In;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Out;
      
      import javax.ejb.Remove;
      import javax.ejb.Stateful;
      import javax.faces.model.DataModel;
      import javax.faces.model.ListDataModel;
      import javax.persistence.EntityManager;
      import javax.persistence.Query;
      import java.util.List;
      
      
      @Stateful
      @Name("testAction")
      
      public class TestAction implements TestActionInterface
      {
        @In(create = true)
        EntityManager entityManager;
      
        @Out(required = false)
        DataModel messages = new ListDataModel();
      
        public String loadData()
        {
          runQuery(entityManager.createQuery("SELECT t FROM Test t"));
          return "test";
        }
      
        protected void runQuery(Query query)
        {
          List list = query.getResultList();
          messages.setWrappedData(list);
        }
      
        protected void runQuery(String query)
        {
          List list = entityManager.createQuery(query).getResultList();
          messages.setWrappedData(list);
        }
      
        @Remove
        @Destroy
        public void destroy()
        {
        }
      
      }
      
      



      SFSB Interface


      package de.test.calc.workflow;
      
      import javax.ejb.Local;
      import java.io.Serializable;
      
      
      @Local
      
      public interface TestActionInterface extends Serializable
      {
        public String loadData();
        public void destroy();  
      }
      



      test.jsp


      <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
      <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
      <%@ taglib uri="http://jboss.com/products/seam/taglib" prefix="s" %>
      
      <f:view>
      
      
      <h:form>
      
        <h:dataTable headerClass="main_kopf" value="#{messages}" var="c">
      
          <h:column>
            <f:facet name="header">
                <h:outputText value="Von"/>
            </f:facet>
            <h:outputText value="#{c.subject}"/>
          </h:column>
      
          <h:column>
            <f:facet name="header">
                <h:outputText value="An"/>
            </f:facet>
            <h:outputText value="#{c.body}"/>
          </h:column>
      
          <h:column>
            <f:facet name="header">
              <h:outputText value="Subject"/>
            </f:facet>
            <h:outputText value="#{c.subject}"/>
          </h:column>
      
      
        </h:dataTable>
      
      
      </h:form>
      
      
      </f:view>
      

        • 1. Re: Bug in Seam 2.0.1 ? Please help.
          Carsten Hoehne Master

          I am not a member of the JBoss Team but  ihave tested your app.


          Your app raises the named exception even with this simple jsp-page:



          <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
          
          <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
          
          <%@ taglib uri="http://jboss.com/products/seam/taglib" prefix="s" %>
          
          
          <f:view>
          
          
          
          <h:form>
          
          
                   <h:outputText value="Von"/>
          
          </h:form>
          
          
          
          </f:view>



          So i assume a configuration error. For detecting this, i recommend one of 3 ways:




          1. investigating the seam examples

          2. use the commandline tool seam-gen (comes with seam) to setup a project

          3. use eclipse togehter with JBoss Tools to setup a Seam project



          i would go for 3.


          Also, try to get rid of jsp. Use facelets together with xhtml whereever possible.

          • 2. Re: Bug in Seam 2.0.1 ? Please help.
            Georges Goebel Newbie

            Hi


            I also tried your simple page but that works for me. But I totally agree with you to switch to facelets.


            Can you post the source code so I don't need to decompile and a build script (I know I am lazy :-) )


            Georges


            <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
            <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
            <%@ taglib uri="http://jboss.com/products/seam/taglib" prefix="s" %>
            
            <f:view>
            
            
            <h:form>
            
                     <h:outputText value="Von"/>
            </h:form>
            
            
            </f:view>
            
            

            • 3. Re: Bug in Seam 2.0.1 ? Please help.
              Toni Beckman Novice

              Hi Carsten,


              that's what I also thought at first. That something is wrong with the config files.


              However, I have gone over them several times for the last 3 days. I also created a clean project with seam-gen and read the docs.


              If you deploy the application and run it, then you will see that this error is strange.


              You can also look at the configuration files, but they are like the source code very simple.


              And I think this bug could exist, because people focus these days only on facelets.


              • 4. Re: Bug in Seam 2.0.1 ? Please help.
                Toni Beckman Novice

                Hi Georges,


                that's all the source code there is. The configuration files you can find in the archive.

                • 5. Re: Bug in Seam 2.0.1 ? Please help.
                  Toni Beckman Novice

                  Carsten Höhne wrote on Feb 27, 2008 11:57 AM:


                  I am not a member of the JBoss Team but  ihave tested your app.

                  Your app raises the named exception even with this simple jsp-page:


                  <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
                  <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
                  <%@ taglib uri="http://jboss.com/products/seam/taglib" prefix="s" %>
                  
                  <f:view>
                  
                  
                  <h:form>
                  
                           <h:outputText value="Von"/>
                  </h:form>
                  
                  
                  </f:view>






                  Carsten, there is a page event, which wtriggers the loadData() function in the SFSB every time you call /test.seam - that's why you even get the Exception, when you modify the JSP page.

                  • 6. Re: Bug in Seam 2.0.1 ? Please help.
                    Carsten Hoehne Master

                    there is a page event, which wtriggers the loadData()

                    i overlooked that:-(

                    • 7. Re: Bug in Seam 2.0.1 ? Please help.
                      Carsten Hoehne Master

                      Are you able to give us the source project for download. So that i do not have assemble it for myself?


                      Here is an interesting stacktrace from my jboss log.
                      According to that, the statefulbean is destroyed before the exception raises.


                      2008-02-27 13:48:38,046 DEBUG [org.jboss.seam.core.Events] Processing event:org.jboss.seam.postSetVariable.entityManager
                      
                      2008-02-27 13:48:38,046 DEBUG [org.jboss.seam.contexts.Contexts] found in conversation context: org.jboss.seam.persistence.persistenceContexts
                      
                      2008-02-27 13:48:38,046 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.events
                      
                      2008-02-27 13:48:38,046 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.events
                      
                      2008-02-27 13:48:38,046 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.events
                      
                      2008-02-27 13:48:38,046 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.events
                      
                      2008-02-27 13:48:38,046 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.events
                      
                      2008-02-27 13:48:38,046 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.events
                      
                      2008-02-27 13:48:38,046 DEBUG [org.jboss.seam.core.Events] Processing event:org.jboss.seam.postCreate.entityManager
                      
                      2008-02-27 13:48:38,046 DEBUG [org.jboss.seam.util.Naming] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
                      
                      2008-02-27 13:48:38,046 DEBUG [org.jboss.seam.util.Naming] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
                      
                      2008-02-27 13:48:38,046 DEBUG [org.jboss.seam.contexts.Contexts] found in conversation context: org.jboss.seam.persistence.persistenceContexts
                      
                      2008-02-27 13:48:38,046 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.events
                      
                      2008-02-27 13:48:38,046 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.events
                      
                      2008-02-27 13:48:38,046 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.events
                      
                      2008-02-27 13:48:38,046 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.events
                      
                      2008-02-27 13:48:38,046 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.events
                      
                      2008-02-27 13:48:38,046 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.events
                      
                      2008-02-27 13:48:38,046 DEBUG [org.jboss.seam.core.Events] Processing event:org.jboss.seam.preRemoveVariable.testAction
                      
                      2008-02-27 13:48:38,046 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.events
                      
                      2008-02-27 13:48:38,046 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.events
                      
                      2008-02-27 13:48:38,046 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.events
                      
                      2008-02-27 13:48:38,046 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.events
                      
                      2008-02-27 13:48:38,046 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.events
                      
                      2008-02-27 13:48:38,046 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.events
                      
                      2008-02-27 13:48:38,046 DEBUG [org.jboss.seam.core.Events] Processing event:org.jboss.seam.postRemoveVariable.testAction
                      
                      2008-02-27 13:48:38,046 DEBUG [org.jboss.seam.ejb.RemoveInterceptor] Stateful component was removed: testAction
                      
                      2008-02-27 13:48:38,046 ERROR [org.jboss.seam.jsf.SeamPhaseListener] uncaught exception
                      
                      javax.el.ELException: javax.ejb.EJBTransactionRolledbackException



                      • 8. Re: Bug in Seam 2.0.1 ? Please help.
                        Toni Beckman Novice

                        Carsten Höhne wrote on Feb 27, 2008 02:03 PM:


                        Are you able to give us the source project for download. So that i do not have assemble it for myself?



                        I have assembled the project directory. If you extract the following archive http://213.239.213.83/test-seam2.tgz and  change into the build directory and run ant then project will be deployed to /opt/jboss/server/default/deploy/


                        I have also noticed that the SFSB is being destroyed. That's probably the problem. I think that in the end when seam tries to put the SFSB into the CONVESATION scope, then it's missing the Bean and runs into a NullPointerException.


                        But you agree that the application is to trivial, that it should run without problems?


                        • 9. Re: Bug in Seam 2.0.1 ? Please help.
                          Carsten Hoehne Master


                          But you agree that the application is to trivial,

                          No, due to the fact that i needed some time to understand it. And you have used javax.faces.model.DataModel as type for messages instead of a simple List or Set.


                          Seam does have a componnent called messages. It is the seam message bundle. Perhaps here is an name clash?


                          Your provided project does not have a compile target in ant and it is not in th project structures i am used to. (BTW: Which IDE do you use IDEA?)
                          So i can not test my assumptions, because i am not able to compile my changes.


                          Please try for yourself and report. But i assume that you really know the answer:-)