2 Replies Latest reply on May 31, 2010 12:16 PM by Shu Tan

    Seam tests with TestNG eclipse plugin

    YATIM Khalid Newbie

      I'm trying to test my seam components using TestNG eclipse plugin.


      When runing my test i have the following error :




      FAILED: testMethod
      java.lang.IllegalArgumentException: Unknown entity: my.domain.MyEntity
           at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:223)



      I'm using test project that was generated by Seam Tool in eclipse.


      I use Seam (jboss-seam-2.2.1.CR1)


        • 1. Re: Seam tests with TestNG eclipse plugin
          Shu Tan Newbie

          I am experiencing the same thing. I can't persist my entity if I have 2 ejbs. For example, if my Eclipse workspace structure is:


          - EJB1.ejb
          - EJB2.ejb
          - War.war
          - Ear.ear (depends on both EJB1 and EJB2)
          - Project-test


          Then running a test in Project-test via the TestNG plugin will fail on the persist():


          java.lang.IllegalArgumentException: Unknown entity: com.test.entity.Role
               at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:223)


          The Role entity lives in EJB2. Running this as a deployed app in JBoss 5.1.0 GA works with no problems. I am using Seam 2.2.0.


          If I remove EJB1 then the TestNG test will work.

          • 2. Re: Seam tests with TestNG eclipse plugin
            Shu Tan Newbie

            Sorry the project structure list didn't format correctly. Here it is again:


            - EJB1.ejb 
            - EJB2.ejb (this is where my entity lives)
            - War.war 
            - Ear.ear (depends on both EJB1 and EJB2) 
            - Project-test
            



            I have more information. It looks like each EJB has a SessionFactoryImpl. When the SessionFactory is initialized it only reads entities from the same EJB. So the SessionFactoryImpl for EJB1 knows of no entities. When debugging into the persist code it looks like it consults the SessionFactoryImpl for EJB1, therefore has no knowledge of my entity that lives in EJB2. In a real deployment I can use the jar-file element in persistence.xml to handle this. Is there an equivalent for this in a TestNG SeamTest?