Share persistence units between ejb-jars

From Thorgull
Jump to: navigation, search

Scope

You have an ear package with multiple ejb packages inside and many of the ejb' packages need to access the same datasource.

Solution

  • Create a persistence.jar package which will contains only the persistence.xml file.
  • Put this jar in the lib directory of the ear package.
  • Add the following block to the application.xml descriptor
 <module>
   <java>lib/peristence.jar</java>
 </module>