users@glassfish.java.net

Re: Correct packaging for EJBs in WAR or EAR.

From: <glassfish_at_javadesktop.org>
Date: Thu, 22 Apr 2010 13:16:25 PDT

Thanks for the suggestions guys. They gave me enough ideas that I should be able to get things set up to my liking. Creating a dedicated module for persistence.xml seems to give some extra packaging flexibility.

However, I now realize I'm confused about a more basic issue. With JavaEE 6, where is persistence.xml supposed to get put? I used to keep it in the module with my JPA entities. However, I was having trouble with the persistence unit not getting recognized and moved persistence.xml into my EJB module. See here:

http://forums.java.net/jive/thread.jspa?threadID=78910

Today I moved persistence.xml back into the (dedicated) POJO module with my JPA entities and it worked the way I originally expected. I'm starting to think that moving persistence.xml into my EJB module was a mistake. My EJB module has no JPA entities. They are all in the dedicated POJO module.

I suppose I'll have to go back a few days in my SVN repo and see if I can track down what was causing my original problem.

Just to clarify, with JavaEE 6 is it still ok for me to put all of my JPA entities + persistence.xml into a dedicated POJO module that gets deployed to /lib for an EAR (or WEB-INF/lib for a WAR)?

I also found this blog post which has some decent packaging tips (just in case it's useful for anyone coming through a search engine):

http://workflow.imixs.org/roller/ralphsjavablog/entry/jee6_and_packaging_an_ear
[Message sent by forum member 'jptech']

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