1 Reply Latest reply on Jul 8, 2009 8:06 PM by karypid

    Testing Seam applications with shared persistence contexts

      Hi,


      I am following up on this forum post, which describes how to share a persistence context across multiple modules of an ear-based project. I followed the suggestion there, but now I have the following problem: the Jboss Embedded EJB container used in my integration test project cannot see the shared persistence unit.


      My exact situation is as follows:


      I started out with a project generated by JBossTools 3.0.1 (creates four Eclipse projects: prj, prj-ejb, prj-ear and prj-test). I have just created a separate project prj-entities to hold entities as suggested in the forum post above (and added it as a <java> module in the application.xml of prj-ear). I moved all entities and the META-INF/persistence.xml that were in prj-ejb into prj-entities.


      I have added prj-entities to the classpath of prj-test, but still TestNG fails on startup because it cannot resolve the references from session beans in prj-ejb to the persistence context defined in prj-entities...


      How would one go about configuring the embedded EJB container to scan and detect this persistence unit? Since prj-entities is in the classpath (both at compile and runtime), I would expect its META-INF/persistence.xml to be picked up...

        • 1. Re: Testing Seam applications with shared persistence contexts

          Ok, I found the solution after fiddling around some more. Apparently, since there is no EAR in the test project, there is no application.xml as well to instruct the container to parse the the prj-entities class folder for peristence units.


          The solution is to have a persistence.xml file in the prj-test/META-INF folder and declare the presistence unit there. In this case you must also list all entities using <class> tags inside that persistence.xml. This way, the embedded JBoss will pick it up and integration tests will work.