How to reuse EJB in Java EE 5+
I have a few common entity beans that I want to use开发者_Python百科 in EJB module1, and EJB module2. EJB module1 may or may not be in the same EAR as EJB module2 and both EJB modules will be persist to different databases. What's the best way to reuse the common EJBs? should they be package as a JAR file or as EJB jar file?
After playing around with it a bit packaging the common EJBs in it's own EJB jar makes the most sense.
Create an EJB project and add common entity beans. No persistence.xml file is need for this project
Export the project as an EJB jar file.
Add the jar file to the dependant EJB modules. Be sure to add the classes name in the persistence-unit of the dependant EJB modules's persistence.xml.
Hopefully this help someone with similar newbie question.
精彩评论