3 Replies Latest reply on Jun 14, 2010 2:42 AM by alartin

    Stack must not be null in componenttest

    scourge

      When executing a basic component test on an entity component created with the EntityHome patters i consistently get a stack exception from within the seam libraries.


      The source of the problem seems to be an @begin annotation to register the home interface in a long running transaction.


      Does anyone have a clue where the initialisation of the seam framework goes wrong within a componenttest?



      org.jboss.seam.InstantiationException: Could not instantiate Seam component: userHome
           at org.jboss.seam.Component.newInstance(Component.java:2144)
           at org.jboss.seam.Component.getInstance(Component.java:2021)
           at org.jboss.seam.Component.getInstance(Component.java:1983)
           at org.jboss.seam.Component.getInstance(Component.java:1977)
           at org.jboss.seam.Component.getInstanceFromFactory(Component.java:2073)
           at org.jboss.seam.Component.getInstance(Component.java:2011)
           at org.jboss.seam.Component.getInstance(Component.java:1983)
           at org.jboss.seam.Component.getInstance(Component.java:1977)
           at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:55)
           at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:50)
           at org.jboss.seam.el.SeamELResolver.resolveBase(SeamELResolver.java:147)
           at org.jboss.seam.el.SeamELResolver.getValue(SeamELResolver.java:51)
           at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
           at org.jboss.el.parser.AstIdentifier.getValue(AstIdentifier.java:44)
           at org.jboss.el.parser.AstValue.getTarget(AstValue.java:34)
           at org.jboss.el.parser.AstValue.setValue(AstValue.java:83)
           at org.jboss.el.ValueExpressionImpl.setValue(ValueExpressionImpl.java:249)
           at org.jboss.seam.core.Expressions$1.setValue(Expressions.java:117)
           at org.jboss.seam.mock.AbstractSeamTest$ComponentTest.setValue(AbstractSeamTest.java:152)
           at scrumCenter.UserTest$1.testComponents(UserTest.java:23)
           at org.jboss.seam.mock.AbstractSeamTest$ComponentTest.run(AbstractSeamTest.java:162)
           at scrumCenter.UserTest.userCreationTest(UserTest.java:33)
      Caused by: java.lang.IllegalArgumentException: Stack must not be null
           at org.jboss.seam.core.ConversationEntry.<init>(ConversationEntry.java:45)
           at org.jboss.seam.core.ConversationEntries.createConversationEntry(ConversationEntries.java:53)
           at org.jboss.seam.core.Manager.createConversationEntry(Manager.java:664)
           at org.jboss.seam.core.Manager.beginConversation(Manager.java:685)
      ...
      





      public class UserTest extends SeamTest 
      {
           @Test
           public void userCreationTest() throws Exception
           {
                new ComponentTest() 
                {
                
                     @Override
                     protected void testComponents() throws Exception
                     {
                          
                          setValue("#{user.username}", "TST");
                          setValue("#{user.name}", "lstname");
                          setValue("#{user.password}", "secret");
                          invokeMethod("#{userHome.persist}");
                          assert getValue("#{user.username}").equals("TST");
                          assert getValue("#{user.name}").equals("lstname");
                          assert getValue("#{user.password}").equals("secret");
                     }
                }.run();               
           }
      }
      




      @Name("userHome")
      @Scope(ScopeType.SESSION)
      public class UserHome extends EntityHome<User>
      {
      
           private static final long serialVersionUID = -1655875997161469493L;
           @RequestParameter Long userId;
      
      
          @Override
          public Object getId()
          {
              if (userId == null)
              {
                  return super.getId();
              }
              else
              {
                  return userId;
              }
          }
          
          @Factory("user")
          public User getUserInstance()
          {
               return this.getInstance();
          }
      
          
          @Override 
          @Begin
          public void create() {
              super.create();
      }   
      }
      


        • 1. Re: Stack must not be null in componenttest
          blabno

          This exception is pain in the ###. After lots of debugging I found out that you get some exception in place unpredicted by Seam developers (i.e. during restore view phase). Once such unhandled exception is thrown then in production environment most probably you will get Stack must not be null in every request in the same session, and while running seam tests you will get it on every next test.


          Note that by unhandled exception i mean unhandled even by Seam (which does some cleanup before throwing the exception further), which should handle all exceptions (there is a bug in my opinion).


          Same issue here : SeamTestAndCouldNotCommitTransaction

          • 2. Re: Stack must not be null in componenttest
            alartin

            I got the same error. In a seam-gen generated application:
            for an EntityHome seam component, the exceptions are :
            org.jboss.seam.InstantiationException: Could not instantiate Seam component
            Caused by: java.lang.IllegalArgumentException: Stack must not be null


            Really frustrated after figuring it out for the whole day but failed.
            Can somebody help?

            • 3. Re: Stack must not be null in componenttest
              alartin

              The only workaround is to set the EntityHome as a component manually in the seam test. I can not figure it out yet, but you can see My Post.