users@glassfish.java.net

Re: CDI broken between EJB and JPA modules

From: Sahoo <Sahoo_at_Sun.COM>
Date: Fri, 09 Apr 2010 08:44:19 +0530

Witold Szczerba wrote:
> 2010/4/8 Sahoo <Sahoo_at_sun.com>:
>
>> Don't call JPA.jar a module. There are only four module types in Java EE:
>> ejb, web, appclient and rar. JPA.jar is a library jar, so if you place it in
>> lib directory of ear file, things should work as well.
>>
>> Sahoo
>>
>
> Hi again,
> you are correct, a JAR file with persistence unit is not a "module" if
> you define "module" as Java EE artifact.
> The other thing is, once I had one EJB module with JPA defined inside
> and I could not manage to separate it. I did it as documentation says:
> simple JAR, jpa-entities.jar for example, with
> META-INF/persistence.xml placed in EAR/lib - it does not work, at
> least in Glassfish v2.1. It started to work when I placed that
> jpa-entities.jar file in root of EAR, like this:
> ExampleApp.ear
> /ejbModule1.jar
> /ejbModule2.jar
> /warModule1.jar
> /jpa-entities.jar
>
> I am not sure if the documentation I was reading was wrong or
> Glassfish does it it's own, incorrect way.
>
>

You must have done something incorrectly. The following packaging is
known to work and it is recommended for an ear file:

ear
     lib/
         entities.jar (along with META-INF/persistence.xml)
         ejb-interfaces.jar
     ejb.jar
     some.war

Check out [1] for example which has a working sample with this structure.

Thanks,
Sahoo
[1]
http://weblogs.java.net/blog/ss141213/archive/2005/12/using_java_pers.html