5 Replies Latest reply on Oct 15, 2008 7:14 PM by Gabriel Goïc

    jdniPattern exception in TestNG tests

    Ben Moore Newbie

      Hi,


      I wrote my first, simple TestNG test, extending SeamTest just like the examples. The test itself is empty and does nothing. When I run it, I get the following exception:


      Caused by: java.lang.IllegalArgumentException: You must specify org.jboss.seam.core.init.jndiPattern or use @JndiName: userSearch
           at org.jboss.seam.Component.getJndiName(Component.java:438)
           at org.jboss.seam.Component.<init>(Component.java:243)
           at org.jboss.seam.Component.<init>(Component.java:217)
           at org.jboss.seam.init.Initialization.addComponent(Initialization.java:961)
           ... 27 more
      ... Removed 22 stack frames


      Is this a classpath issue? I've added all sorts of jars to the classpath but still get the exception.


      Environment: IBM RAD 6.1.


      Thanks in advance for any help,
      Bill

        • 1. Re: jdniPattern exception in TestNG tests
          Ben Moore Newbie

          Anyone? I don't even know where to begin looking...

          • 2. Re: jdniPattern exception in TestNG tests
            Florent Blondeau Newbie

            Hi,


            I write here to know if you've found a solution to your problem, because I'm facing the same right now...



            FAILED CONFIGURATION: @BeforeClass init
            java.lang.RuntimeException: Could not create Component: myComponent
                    at org.jboss.seam.init.Initialization.addComponent(Initialization.java:976)
                    at org.jboss.seam.init.Initialization.installComponents(Initialization.java:898)
                    at org.jboss.seam.init.Initialization.init(Initialization.java:576)
                    at org.jboss.seam.mock.BaseSeamTest.startSeam(BaseSeamTest.java:939)
                    at org.jboss.seam.mock.BaseSeamTest.init(BaseSeamTest.java:923)
                    at org.jboss.seam.mock.SeamTest.init(SeamTest.java:42)
            Caused by: java.lang.IllegalArgumentException: You must specify org.jboss.seam.core.init.jndiPattern or use @JndiName: myComponent
                    at org.jboss.seam.Component.getJndiName(Component.java:438)
                    at org.jboss.seam.Component.<init>(Component.java:243)
                    at org.jboss.seam.Component.<init>(Component.java:217)
                    at org.jboss.seam.init.Initialization.addComponent(Initialization.java:961)
                    ... 27 more
            ... Removed 22 stack frames




            My components.xml for tests uses this jndi pattern


            #{ejbName}/local




            My classpath uses :
            jboss-embedded-all.jar
            hibernate-all.jar
            thirdparty-all.jar
            testng.jar
            bootstrap (a folder that I picked from Seam and imported without any modification... I would be glad to know if tests could work without this one)


            Any clue to make this work ?
            Does someone know a resource that explain exactly how the Seam tests work with testng ?


            Thanks


            Dazzx


            PS : I tried to create a project with seam-gen to see tests working, but It didn't work...

            • 3. Re: jdniPattern exception in TestNG tests
              Ben Moore Newbie

              No, I haven't gotten it working. Instead, I thought I'd try to get out-of-the-box TestNG tests (from seam-gen) working with JBoss. I can't even get those to work, although the error is slightly different. See my new post here.

              • 4. Re: jdniPattern exception in TestNG tests
                Alexey Kakunin Newbie

                I had same issues - finally it was resolved by adding web-root folder into test-run class-path (how to do it - depends from IDE you are using - I used NetBeans and JUnit4 to run tests)


                Since web-root is not added into class-path, test runner cannot find WEB-INF/components.xml during Seam initialization - and used default settings

                • 5. Re: jdniPattern exception in TestNG tests
                  Gabriel Goïc Newbie
                  Same here... if you're testing a project that is a dependency and has no descriptors, just make sure your test-build/META-INF directory (assuming you're building in a seam-gen-friendly way) does contain components.xml (and persistence.xml if you're also testing DB access). In components.xml make sure you have the following:


                  `<core:init debug="true" jndi-pattern="#{ejbName}/local"/>`

                  There is no ear named in this jndi pattern as you're outside any ear.

                  An alternative consists in putting this into your seam.properties:

                  org.jboss.seam.core.init.jndiPattern = #{ejbName}/local

                  Anyway, you need this bootstrap directory in your test classpath if you want any advanced feature while testing. For example, this is where you deploy your datasource descriptor (bootstrap/deploy).