2 Replies Latest reply on Nov 27, 2009 2:11 PM by Geert Snick

    Error testing long running transaction

    Geert Snick Newbie

      Hello,



      I've got a basic EntiyHome object i would like to test:


      @Name("userHome")
      @Scope(ScopeType.SESSION)
      public class UserHome extends EntityHome<User>
      {
      
           private static final long serialVersionUID = -1655875997161469493L;
           @RequestParameter Long userId;
          @Logger private Log log;
      
           String confirmPassword = null;
      
          @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();
          }
      }
      



      Any test instantiating this object fails:


      public class UserTest extends SeamTest 
      {
           @Test
           public void userCreationTest() throws Exception
           {
                new ComponentTest() 
                {
                     @Override
                     protected void testComponents() throws Exception
                     {
                          
      
                          invokeMethod("#{userHome.persist}");
      
                     }
                }.run();               
           }
      }
      



      The stacktrace:


      FAILED: userCreationTest
      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:22)
           at org.jboss.seam.mock.AbstractSeamTest$ComponentTest.run(AbstractSeamTest.java:162)
           at scrumCenter.UserTest.userCreationTest(UserTest.java:32)
      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)
           at org.jboss.seam.core.ConversationInterceptor.beginConversation(ConversationInterceptor.java:229)
           at org.jboss.seam.core.ConversationInterceptor.beginConversationIfNecessary(ConversationInterceptor.java:166)
           at org.jboss.seam.core.ConversationInterceptor.aroundInvoke(ConversationInterceptor.java:57)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.transaction.TransactionInterceptor$1.work(TransactionInterceptor.java:97)
           at org.jboss.seam.util.Work.workInTransaction(Work.java:47)
           at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:91)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.core.SynchronizationInterceptor.aroundInvoke(SynchronizationInterceptor.java:32)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
           at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)
           at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
           at org.domain.scrumcenter.session.UserHome_$$_javassist_seam_2.create(UserHome_$$_javassist_seam_2.java)
           at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
           at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
           at org.jboss.seam.Component.callComponentMethod(Component.java:2249)
           at org.jboss.seam.Component.callCreateMethod(Component.java:2172)
           at org.jboss.seam.Component.newInstance(Component.java:2132)
           ... 43 more
      ... Removed 26 stack frames
      



      The error seems to be caused by the @Begin annotation i use to put the Home object in a longliving scope.


      Anyone an idea what i'm doing wrong here?