users@glassfish.java.net

Correct packaging for EJBs in WAR or EAR.

From: <glassfish_at_javadesktop.org>
Date: Thu, 22 Apr 2010 10:05:52 PDT

Hi,

I'm having trouble figuring out the correct way to package my modules so they'll work with either a .ear or a .war. Assume two modules:

entities.jar (JPA entities)
services.jar (EJB facade for data access)

When I package using a .ear (using Maven), I end up with:

- my-app.ear
--- services.jar
--- /lib/entities.jar

My persistence.xml is in the services.jar module and has:

[code]<jar-file>lib/entities.jar</jar-file>[/code]

When I package using a .war (using Maven), I end up with:

- my-app.war
--- WEB-INF/web.xml
--- WEB-INF/lib/entities.jar
--- WEB-INF/lib/services.jar

My persistence.xml is in the services.jar module and I have to change the jar-file entry to:

[code]<jar-file>entities.jar</jar-file>[/code]

I don't need .ear packaging and intend to put everything in a .war. However, needing to update persistence.xml depending on the packaging I'm going to use has me worried that I may be doing something wrong.

Is there a better way? I've spent a few hours searching for an answer, but everyone seems to have their own way of doing it. Any help would be appreciated.

Ryan
[Message sent by forum member 'jptech']

http://forums.java.net/jive/thread.jspa?messageID=398538