1 Reply Latest reply on May 25, 2011 6:50 AM by davidmiller

    TestNG: Could not instantiate Seam component

    davidmiller
      Hi All,

      I hope you can help me.
      I am testing a simple SeamTest to see if my test project will run TestNG and JBoss Embedded.
      However I am getting the following error:

      FAILED CONFIGURATION: @BeforeSuite startSeam
         [testng] org.jboss.seam.InstantiationException: Could not instantiate Seam component: countryList
         [testng]      at org.jboss.seam.Component.newInstance(Component.java:2170)
         [testng]      at org.jboss.seam.contexts.Contexts.startup(Contexts.java:305)
         [testng]      at org.jboss.seam.contexts.Contexts.startup(Contexts.java:279)
         [testng]      at org.jboss.seam.contexts.ServletLifecycle.endInitialization(ServletLifecycle.java:142)
         [testng]      at org.jboss.seam.init.Initialization.init(Initialization.java:744)
         [testng]      at org.jboss.seam.mock.AbstractSeamTest.startSeam(AbstractSeamTest.java:919)
         [testng]      at org.jboss.seam.mock.SeamTest.startSeam(SeamTest.java:58)
         [testng] Caused by: javax.naming.NameNotFoundException: CMS-ear not bound
         [testng]      at org.jnp.server.NamingServer.getBinding(NamingServer.java:542)
         [testng]      at org.jnp.server.NamingServer.getBinding(NamingServer.java:550)
         [testng]      at org.jnp.server.NamingServer.getObject(NamingServer.java:556)
         [testng]      at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
         [testng]      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:669)
         [testng]      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:629)
         [testng]      at javax.naming.InitialContext.lookup(Unknown Source)
         [testng]      at org.jboss.seam.Component.instantiateSessionBean(Component.java:1403)
         [testng]      at org.jboss.seam.Component.instantiate(Component.java:1367)
         [testng]      at org.jboss.seam.Component.newInstance(Component.java:2148)
         [testng]      ... 21 more

      The test I'm running is this:
      public class RunSeamTest extends SeamTest{
           @Test
           public void testRunSeamTest() throws Exception {
                new ComponentTest() {
                     @Override
                     protected void testComponents() throws Exception {
                     }
                }.run();
           }
      }

      I must be missing something obvious(again).

      Thanks in advance,

      Dave
        • 1. Re: TestNG: Could not instantiate Seam component
          davidmiller

          Finally got to the bottom of this, so will post my solution in the hope it will help someone else.


          It all came down to the datasource.  An SQL statement was failing and subsequently the components could not instantiate.  I was running it both through ant and the TestNG plugin and discovered that the TestNG plugin in Eclipse picks up the datasource from the META-INF directory within the test source.  This was set incorrectly.  I amended this to be correct and moved it to the bootstrap/deploy folder and it worked.


          Dave