users@glassfish.java.net

one persistence unit for few EJB modules in one EAR

From: Witold Szczerba <pljosh.mail_at_gmail.com>
Date: Mon, 19 Jan 2009 17:47:34 +0100

Hi there,
can you, please, tell me how should I package my EAR file with one,
two or more EJB modules in a way that every EJB module could share one
persistence unit? I was trying different things, so please spare me
describing what I tried and did not work. Right now all I can get is
to put persistence.xml file inside one of EJB module. But that module
is the only one where I can inject EntityManager.
As soon as I move persistence.xml from within EJB-JAR somewhere else,
I cannot deploy EAR, because session beans of that EJB-EAR cannot find
persistence unit anymore.

This is what I get when deploying:

Exception occured in J2EEC Phase
com.sun.enterprise.deployment.backend.IASDeploymentException: Could
not resolve a persistence unit corresponding to the
persistence-context-ref-name
[pl.ibpolsoft.netbroker.core.services.DummyEJBBean/em] in the scope of
the module called
[gfdeploy#/home/witoldsz/NetBeansProjects/netBroker/netBroker-ear/dist/gfdeploy/netBroker-ejb_jar].
Please verify your application.

The bottom line is I would like to be able to make my application
(EAR) of several EJB modules, so they would be able to communicate
using local interfaces and share one persistence unit. Can you tell me
how exactly should my EAR and EJBs look like?

Thanks,
Witold Szczerba