1 Reply Latest reply on Jul 9, 2009 1:24 AM by Alexandros Karypidis

    TestNG SeamTest injections

    Alexandros Karypidis Novice

      Hi,


      My Seam actions are session beans in an ejb-jar. These actions reference session beans in other ejb-jars that are also included in the seam EAR. Those sessions beans are injected using the standard @EJB annotation. Although this works fine in my application, it causes problems in TestNG tests that reference these actions. During startup, initialization fails (SeamTest.init()) because the persistence units and session beans cannot be located.


      The structure of my project is as follows:


      myapp (seam WAR)
      myapp-ejb (seam actions as session beans)
      myapp-ear (application bundle)
      myapp-test (testng project)
      
      myapp-logic (more session beans with business logic)
      myapp-punit (EAR-scoped persistence unit as <java> module)
      



      So, a seam action class (e.g. RegisterAction) in myapp-ejb may reference some session bean's @Local interface which is packaged in myapp-logic, using a @EJB injection. In addition, it may reference the persistence unit defined in the persistence.xml of myapp-punit using @PersistenceContext.


      When deployed to JBoss, all works well. When the testng test runs, I get deployment errors due to missing dependencies:


      FAILED CONFIGURATION: @BeforeClass init
      org.jboss.deployers.client.spi.IncompleteDeploymentException: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):
      
      *** CONTEXTS MISSING DEPENDENCIES: Name -> Dependency{Required State:Actual State}
      
      jboss.j2ee:jar=classes,name=AuthenticatorBean,service=EJB3
       -> <UNKNOWN>{Described:** UNRESOLVED Demands 'persistence.units:jar=myapp-punit.jar,unitName=myapp-core **}
      
      jboss.j2ee:jar=classes,name=RegisterActionBean,service=EJB3
       -> <UNKNOWN>{Described:** UNRESOLVED Demands 'Class:myapp.services.utility.CoreEntitiesService **}
      



      Now, the above is caused beofre any test code is accessed (my SeamTest is empty) while testng tries to create the mock environment. As far as I understand, it sees myapp-ejb in the classpath, finds the RegisterActionBean class and tries to resolve the @EJB CoreEntititesService in the seam action and looks for CoreEntititesService (this is a session bean defined in myapp-logic.jar which is also in the classpath)  but cannot find it.


      How can I fix this?