7 Replies Latest reply on May 20, 2010 12:38 PM by simonkent

    Integration tests not working : name not bound

    simonkent

      Hello Seam Community,


      Having an issue with Seam and TestNG, if anyone can help me.
      I'm trying to do some integration testing with TestNG and seam (2.2)
      No matter what I do, when I run the tests, I get a NameNotFoundException. I checked and rechecked all the files (the app deploys and runs without issues on jboss 4.2.3)
      The application deploys well in the first phase, but it crashed when it tries to load a component from the seam container - this happens in the startup phase (I have some code that is executed at startup).




        [testng]     at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
        [testng]     at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
        [testng]     at org.jboss.seam.Component.callComponentMethod(Component.java:2249)
        [testng]     at org.jboss.seam.Component.callCreateMethod(Component.java:2172)
        [testng]     at org.jboss.seam.Component.newInstance(Component.java:2132)
        [testng]     ... 21 more
        [testng] Caused by: javax.naming.NameNotFoundException: stest 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)





      Any ideas ?
      Kind regards,
      Andrei

        • 1. Re: Integration tests not working : name not bound
          amitev

          When starting JBoss MC do you see a log entries where EJB's get loaded?

          • 2. Re: Integration tests not working : name not bound
            simonkent

            Hello,


            Yes, I do see them. I switched to a more detailed logging, and this is the relevant part of the output :



               [testng] INFO  [org.jboss.jms.server.ServerPeer] JBoss Messaging 1.4.0.SP1 server [0] started
               [testng] INFO  [org.jboss.jms.server.destination.QueueService] Queue[/queue/DLQ] started, fullSize=200000, pageSize=2000, downCacheSize=2000
               [testng] WARN  [org.jboss.jms.server.connectionfactory.ConnectionFactoryJNDIMapper] supportsFailover attribute is true on connection factory: jboss.messaging.connectionfactory:service=ClusteredConnectionFactory but post office is non clustered. So connection factory will *not* support failover
               [testng] WARN  [org.jboss.jms.server.connectionfactory.ConnectionFactoryJNDIMapper] supportsLoadBalancing attribute is true on connection factory: jboss.messaging.connectionfactory:service=ClusteredConnectionFactory but post office is non clustered. So connection factory will *not* support load balancing
               [testng] INFO  [org.jboss.jms.server.connectionfactory.ConnectionFactory] Connector bisocket://127.0.0.1:4458 has leasing enabled, lease period 10000 milliseconds
               [testng] INFO  [org.jboss.jms.server.connectionfactory.ConnectionFactory] org.jboss.jms.server.connectionfactory.ConnectionFactory@7e9bed started
               [testng] INFO  [org.jboss.jms.server.connectionfactory.ConnectionFactory] Connector bisocket://127.0.0.1:4458 has leasing enabled, lease period 10000 milliseconds
               [testng] INFO  [org.jboss.jms.server.connectionfactory.ConnectionFactory] org.jboss.jms.server.connectionfactory.ConnectionFactory@1ec4333 started
               [testng] INFO  [org.jboss.jms.server.destination.QueueService] Queue[/queue/ExpiryQueue] started, fullSize=200000, pageSize=2000, downCacheSize=2000
               [testng] INFO  [org.jboss.jms.server.connectionfactory.ConnectionFactory] Connector bisocket://127.0.0.1:4458 has leasing enabled, lease period 10000 milliseconds
               [testng] INFO  [org.jboss.jms.server.connectionfactory.ConnectionFactory] org.jboss.jms.server.connectionfactory.ConnectionFactory@5cb0bb started
               [testng] INFO  [org.jboss.resource.connectionmanager.ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=ConnectionFactoryBinding,name=JmsXA' to JNDI name 'java:JmsXA'
               [testng] INFO  [org.jboss.ejb3.deployers.PersistenceUnitParsingDeployer] Found persistence units [org.jboss.ejb3.metadata.jpa.spec.PersistenceUnitMetaData@6abd0b{name=stestBW}]
               [testng] INFO  [org.jboss.ejb3.MCKernelAbstraction] installing bean: persistence.units:jar=test_out.jar,unitName=stestBW with dependencies:
               [testng] INFO  [org.jboss.ejb3.MCKernelAbstraction]   and supplies:
               [testng] INFO  [org.jboss.ejb3.MCKernelAbstraction] installing bean: jboss.j2ee:jar=test_out,name=ActionRunner,service=EJB3 with dependencies:
               [testng] INFO  [org.jboss.ejb3.MCKernelAbstraction]   and supplies:
               [testng] INFO  [org.jboss.ejb3.MCKernelAbstraction]  Class:path.to.my.package.IActionRunner
               [testng] INFO  [org.jboss.ejb3.EJBContainer] STARTED EJB: path.to.my.package.ActionRunner ejbName: ActionRunner
               [testng] WARN  [org.jboss.ejb3.timerservice.jboss.JBossTimerServiceFactory] TIMER SERVICE IS NOT INSTALLED
               [testng] INFO  [org.jboss.resource.connectionmanager.ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=stestBWDatasource' to JNDI name 'java:stestBWDatasource'
               [testng] INFO  [org.jboss.ejb3.entity.PersistenceUnitDeployment] Starting persistence unit persistence.units:jar=test_out.jar,unitName=stestBW
               [testng] WARN  [jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory] Exception trying to create connection checker (disabling):
               [testng] java.lang.ClassNotFoundException: 
               [testng]             com.mysql.jdbc.integration.jboss.MysqlValidConnectionChecker
               [testng]         
               [testng]     at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
               [testng]     at java.security.AccessController.doPrivileged(Native Method)
            ............................................................................[SNIP - exception stacktrace]
               [testng] INFO  [org.jboss.ejb3.MCKernelAbstraction] installing bean: jboss.j2ee:jar=jboss-seam.jar,name=TimerServiceDispatcher,service=EJB3 with dependencies:
               [testng] INFO  [org.jboss.ejb3.MCKernelAbstraction]   and supplies:
               [testng] INFO  [org.jboss.ejb3.MCKernelAbstraction]  Class:org.jboss.seam.async.LocalTimerServiceDispatcher
               [testng] INFO  [org.jboss.ejb3.EJBContainer] STARTED EJB: org.jboss.seam.async.TimerServiceDispatcher ejbName: TimerServiceDispatcher
               [testng] WARN  [org.jboss.ejb3.timerservice.jboss.JBossTimerServiceFactory] TIMER SERVICE IS NOT INSTALLED
               [testng] INFO  [org.jboss.ejb3.MCKernelAbstraction] installing bean: jboss.j2ee:jar=jboss-seam.jar,name=EjbSynchronizations,service=EJB3 with dependencies:
               [testng] INFO  [org.jboss.ejb3.MCKernelAbstraction]   and supplies:
               [testng] INFO  [org.jboss.ejb3.MCKernelAbstraction]  Class:org.jboss.seam.transaction.LocalEjbSynchronizations
               [testng] INFO  [org.jboss.ejb3.EJBContainer] STARTED EJB: org.jboss.seam.transaction.EjbSynchronizations ejbName: EjbSynchronizations
               [testng] INFO  [org.jboss.seam.init.Initialization] reading /WEB-INF/components.xml
               [testng] INFO  [org.jboss.seam.init.Initialization] reading properties from: /seam.properties
               [testng] INFO  [org.jboss.seam.init.Initialization] reading properties from: /jndi.properties
               [testng] INFO  [org.jboss.seam.Component] Component: org.jboss.seam.core.init, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.Init
               [testng] INFO  [org.jboss.seam.init.Initialization] two components with same name, higher precedence wins: org.jboss.seam.async.dispatcher
               [testng] INFO  [org.jboss.seam.init.Initialization] two components with same name, higher precedence wins: org.jboss.seam.web.parameters
               [testng] INFO  [org.jboss.seam.init.Initialization] two components with same name, higher precedence wins: org.jboss.seam.core.resourceLoader
               [testng] INFO  [org.jboss.seam.init.Initialization] two components with same name, higher precedence wins: org.jboss.seam.core.locale
               [testng] INFO  [org.jboss.seam.init.Initialization] two components with same name, higher precedence wins: org.jboss.seam.core.expressions
               [testng] INFO  [org.jboss.seam.init.Initialization] two components with same name, higher precedence wins: org.jboss.seam.web.isUserInRole
               [testng] INFO  [org.jboss.seam.init.Initialization] two components with same name, higher precedence wins: org.jboss.seam.core.resourceLoader
               [testng] INFO  [org.jboss.seam.init.Initialization] two components with same name, higher precedence wins: org.jboss.seam.core.manager
               [testng] INFO  [org.jboss.seam.init.Initialization] two components with same name, higher precedence wins: org.jboss.seam.web.userPrincipal
               [testng] INFO  [org.jboss.seam.init.Initialization] two components with same name, higher precedence wins: org.jboss.seam.captcha.captcha
               [testng] INFO  [org.jboss.seam.init.Initialization] two components with same name, higher precedence wins: org.jboss.seam.core.locale
               [testng] INFO  [org.jboss.seam.init.Initialization] two components with same name, higher precedence wins: org.jboss.seam.persistence.persistenceProvider
               [testng] INFO  [org.jboss.seam.init.Initialization] two components with same name, higher precedence wins: org.jboss.seam.transaction.synchronizations
               [testng] INFO  [org.jboss.seam.Component] Component: STestInit, scope: APPLICATION, type: JAVA_BEAN, class: path.to.my.package.STestInit
               [testng] INFO  [org.jboss.seam.Component] Component: abstractSearchPropertyConverter, scope: CONVERSATION, type: JAVA_BEAN, class: path.to.my.package.AbstractSearchPropertyConverter
               [testng] INFO  [org.jboss.seam.Component] Component: actionHandler, scope: STATELESS, type: STATELESS_SESSION_BEAN, class: path.to.my.package.ActionRunner, JNDI: stest/ActionRunner/local
            .............................................[SNIP - other app specific components listed here]
               [testng] INFO  [org.jboss.seam.Component] Component: org.jboss.seam.async.asynchronousExceptionHandler, scope: STATELESS, type: JAVA_BEAN, class: org.jboss.seam.async.AsynchronousExceptionHandler
               [testng] INFO  [org.jboss.seam.Component] Component: org.jboss.seam.async.dispatcher, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.async.QuartzDispatcher
               [testng] INFO  [org.jboss.seam.Component] Component: org.jboss.seam.cache.cacheProvider, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.cache.JbossCacheProvider
               [testng] INFO  [org.jboss.seam.Component] Component: org.jboss.seam.captcha.captcha, scope: SESSION, type: JAVA_BEAN, class: path.to.my.package.NWCaptcha3
            ---------------------------------------------[SNIP]
               [testng] INFO  [org.jboss.seam.Component] Component: org.jboss.seam.web.session, scope: SESSION, type: JAVA_BEAN, class: org.jboss.seam.web.Session
               [testng] INFO  [org.jboss.seam.Component] Component: org.jboss.seam.web.userPrincipal, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.faces.UserPrincipal
               [testng] INFO  [org.jboss.seam.Component] Component: pageHelper, scope: PAGE, type: JAVA_BEAN, class: path.to.my.package.PageHelper
               [testng] INFO  [org.jboss.seam.Component] Component: passwordStrenghtValidator, scope: EVENT, type: JAVA_BEAN, class: path.to.my.package.ValidatePasswordStrenght
            .................................................................[SNIP : other app specific components listed here]
               [testng] WARN  [org.jboss.seam.security.permission.PersistentPermissionResolver] no permission store available - please install a PermissionStore with the name 'org.jboss.seam.security.jpaPermissionStore' if persistent permissions are required.
               [testng] INFO  [path.to.my.package.PersistenceHelper] Retrieving BWEntityManagerFactory...
               [testng] WARN  [org.jboss.seam.async.QuartzDispatcher] No seam.quartz.properties file. Using in-memory job store.
               [testng] INFO  [org.quartz.simpl.SimpleThreadPool] Job execution threads will use class loader of thread: main
               [testng] INFO  [org.quartz.core.QuartzScheduler] Quartz Scheduler v.1.5.2 created.
               [testng] INFO  [org.quartz.simpl.RAMJobStore] RAMJobStore initialized.
               [testng] INFO  [org.quartz.impl.StdSchedulerFactory] Quartz scheduler 'DefaultQuartzScheduler' initialized from default resource file in Quartz package: 'quartz.properties'
               [testng] INFO  [org.quartz.impl.StdSchedulerFactory] Quartz scheduler version: 1.5.2
               [testng] INFO  [org.quartz.core.QuartzScheduler] Scheduler DefaultQuartzScheduler_$_NON_CLUSTERED started.
               [testng] INFO  [org.jboss.seam.resteasy.ResteasyBootstrap] bootstrapping JAX-RS application
               [testng] INFO  [org.jboss.seam.resteasy.ResteasyBootstrap] registering built-in RESTEasy providers
               [testng] INFO  [org.jboss.resteasy.plugins.providers] Added built in provider DataSourceProvider
               [testng] INFO  [org.jboss.resteasy.plugins.providers] Added built in provider DefaultTextPlain
            --------------[SNIP]
            [testng] INFO  [org.jboss.resteasy.plugins.providers] Adding built in provider org.jboss.resteasy.plugins.providers.jaxb.json.JsonJAXBContextFinder
               [testng] INFO  [org.jboss.resteasy.plugins.providers] Adding built in provider org.jboss.resteasy.plugins.providers.jaxb.fastinfoset.FastinfoSetJAXBContextFinder
               [testng] INFO  [path.to.my.package.MyApp] Reading configuration...
            .....................................................................[SNIP - some app specific logging here]
               [testng] INFO  [path.to.my.package.MyApp] STest configured.
               [testng] FAILED CONFIGURATION: @BeforeSuite startSeam
               [testng] org.jboss.seam.InstantiationException: Could not instantiate Seam component: path.to.my.package.classpathPagesAdder
               [testng]     at org.jboss.seam.Component.newInstance(Component.java:2144)
               [testng]     at org.jboss.seam.contexts.Contexts.startup(Contexts.java:304)
               [testng]     at org.jboss.seam.contexts.Contexts.startup(Contexts.java:278)
               [testng]     at org.jboss.seam.contexts.ServletLifecycle.endInitialization(ServletLifecycle.java:116)
               [testng]     at org.jboss.seam.init.Initialization.init(Initialization.java:740)
               [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: org.jboss.seam.InstantiationException: Could not instantiate Seam component: actionHandler
               [testng]     at org.jboss.seam.Component.newInstance(Component.java:2144)
               [testng]     at org.jboss.seam.Component.getInstance(Component.java:2021)
               [testng]     at org.jboss.seam.Component.getInstance(Component.java:1983)
               [testng]     at org.jboss.seam.Component.getInstance(Component.java:1977)
               [testng]     at org.jboss.seam.Component.getInstance(Component.java:1957)
               [testng]     at path.to.my.package.AbstractSTestApp.init(AbstractSTestApp.java:92)
               [testng]     at path.to.my.package.MyApp.initSTest(MyApp.java:84)
               [testng]     at path.to.my.package.MyApp.getInstance(MyApp.java:137)
               [testng]     at path.to.my.package.ClasspathPagesAdder.create(ClasspathPagesAdder.java:60)
               [testng]     at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
               [testng]     at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
               [testng]     at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
               [testng]     at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
               [testng]     at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
               [testng]     at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
               [testng]     at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
               [testng]     at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
               [testng]     at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)
               [testng]     at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
               [testng]     at path.to.my.package.ClasspathPagesAdder_$$_javassist_seam_5.create(ClasspathPagesAdder_$$_javassist_seam_5.java)
               [testng]     at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
               [testng]     at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
               [testng]     at org.jboss.seam.Component.callComponentMethod(Component.java:2249)
               [testng]     at org.jboss.seam.Component.callCreateMethod(Component.java:2172)
               [testng]     at org.jboss.seam.Component.newInstance(Component.java:2132)
               [testng]     ... 21 more
               [testng] Caused by: javax.naming.NameNotFoundException: stest 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(InitialContext.java:392)
               [testng]     at org.jboss.seam.Component.instantiateSessionBean(Component.java:1400)
               [testng]     at org.jboss.seam.Component.instantiate(Component.java:1364)
               [testng]     at org.jboss.seam.Component.newInstance(Component.java:2122)
               [testng]     ... 53 more
               [testng] ... Removed 23 stack frames
               [testng] SKIPPED CONFIGURATION: @BeforeClass setupClass
               [testng] SKIPPED CONFIGURATION: @BeforeMethod begin
               [testng] SKIPPED CONFIGURATION: @AfterMethod end
               [testng] SKIPPED CONFIGURATION: @AfterClass cleanupClass
               [testng] SKIPPED: testRegistrationSignup
            
            



            Kind regards,
            Andrei

            • 3. Re: Integration tests not working : name not bound
              amitev

              What is 'stest' actually?

              • 4. Re: Integration tests not working : name not bound
                simonkent

                stest is the name of my application (obfuscated, as some other names you see in the stacktrace).
                it is also the context root of the webapp, etc.

                • 5. Re: Integration tests not working : name not bound
                  simonkent

                  Any hints ?
                  Also, a tutorial for setting up TestNG with seam without having the original project generated by seam-gen, would be helpful. I tried to follow the description in the seam documentation, but didn't helped very much...

                  • 6. Re: Integration tests not working : name not bound
                    simonkent

                    ...looks like my problem was caused by a @Stateless annotation on some class that invoked during the startup of the application. I removed it, and not it deploys OK.


                    Does anybody have any idea why this is happening ?

                    • 7. Re: Integration tests not working : name not bound
                      simonkent

                      Forgot to say - I solved my problem, if it helps anybody.
                      It seems that jboss embedded needs a slightly different jndiPattern, so make sure the pattern is changed when running testng. This is written in the seam documentation, in the configuration section, but I just didn't noticed it the first time.
                      Placing this info in the TestNg and seam section, may save someone else a few hours of search :)