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

    Stack must not be null in componenttest

    Geert Snick Newbie

      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();
      }   
      }