3 Replies Latest reply on Jun 12, 2007 2:24 PM by tuxzilla

    Trouble with SeamTest when stateful session bean is annotate

    tuxzilla

      I couldn't get the SFSB to instantiate correctly in my SeamTest because the component startup was invoked before the embedded ejb container startup. Here is the error message:


      org.jboss.seam.InstantiationException: Could not instantiate Seam component: companyList
      at org.jboss.seam.Component.newInstance(Component.java:1740)
      at org.jboss.seam.contexts.Lifecycle.startup(Lifecycle.java:175)
      at org.jboss.seam.contexts.Lifecycle.endInitialization(Lifecycle.java:145)
      at org.jboss.seam.init.Initialization.init(Initialization.java:504)
      at org.jboss.seam.mock.SeamTest.init(SeamTest.java:701)
      Caused by: javax.naming.NamingException: Local server is not initialized
      at org.jnp.interfaces.LocalOnlyContextFactory.getInitialContext(LocalOnlyContextFactory.java:45)
      at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
      at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
      at javax.naming.InitialContext.init(InitialContext.java:223)
      at javax.naming.InitialContext.<init>(InitialContext.java:197)
      at org.jboss.seam.util.Naming.getInitialContext(Naming.java:35)
      at org.jboss.seam.util.Naming.getInitialContext(Naming.java:47)
      at org.jboss.seam.Component.instantiateSessionBean(Component.java:1107)
      at org.jboss.seam.Component.instantiate(Component.java:1093)
      at org.jboss.seam.Component.newInstance(Component.java:1736)



      Here is the log message after I disabled the @Startup annotation of the SFSB:

      15:31:44,187 INFO [Lifecycle] starting up: org.jboss.seam.servlet.exceptionFilter
      15:31:44,187 INFO [Lifecycle] starting up: org.jboss.seam.ioc.spring.springELResolver
      15:31:44,218 INFO [Lifecycle] starting up: org.jboss.seam.ui.resource.webResource
      15:31:44,218 INFO [Lifecycle] starting up: org.jboss.seam.servlet.redirectFilter
      15:31:44,218 INFO [Lifecycle] starting up: org.jboss.seam.core.ejb
      15:31:44,218 INFO [Ejb] starting the embedded EJB container
      15:31:45,328 WARN [BeanSchemaBinding] You should use the 2.0 version of the Microcontainer xml. xmlns='urn:jboss:bean-deployer:2.0'
      ...


      Is there a way I can postpone the startup of this EJB while keeping the @Startup annotation?

      Thanks.



        • 1. Re: Trouble with SeamTest when stateful session bean is anno
          matt.drees

          You can do

          @Startup(depends={"orb.jboss.seam.core.ejb"})
          I think.

          • 2. Re: Trouble with SeamTest when bean is annotated @Startup
            tuxzilla

            Unfortunately it didn't work either. I removed the ejb annotations and made it a POJO. Then I injected entityManager using @In, I got a similar problem, the root of which is due to the micro-container (and the JNDI) not available before the starting up of the bean:


            [testng] 09:49:46,453 INFO [Component] Component: voteCount, scope: CONVERSA
            TION, type: ENTITY_BEAN, class: com.n2.bo.VoteCount
            [testng] 09:49:46,453 INFO [Lifecycle] starting up: entityManager
            [testng] 09:49:46,453 INFO [Lifecycle] starting up: companyList
            [testng] FAILED CONFIGURATION: @BeforeClass init
            [testng] java.lang.IllegalArgumentException: EntityManagerFactory not found i
            n JNDI
            [testng] at org.jboss.seam.core.ManagedPersistenceContext.getEntityManage
            rFactoryFromJndiOrValueBinding(ManagedPersistenceContext.java:164)
            [testng] at org.jboss.seam.core.ManagedPersistenceContext.initEntityManag
            er(ManagedPersistenceContext.java:77)


            • 3. Re: Trouble with SeamTest when stateful session bean is anno
              tuxzilla

              Never mind. On closer inspection, your solution of adding depends={"org.jboss.seam.core.ejb"} worked. Thanks.