Sorry, I forgot to add I'm using JBoss 4.2.2GA
As far as i remember, the persistence units in different EARs are not accessible from the other EAR.
Then I'll have to figure out a different solution. The bbb-ear is a large application with slow release cycles. I'm developing a maintenance application (aaa.ear) that deploys as a stateless EJB that can pull entities from the main application and send data from them to a client through JMX. So the ejb in aaa.ear need to access some entities in bbb and it would be really nice if this could be done through the same persistence context that the main application is using.
This would allow the maintenance guys to hot deploy the hook ear, run some batch jobs and whatnot and undeploy it without having to clutter the main application.
I guess I could connect directly to the datasource, but then the cache would be bypassed and only reads would be possible.
Am I trying to do something impossible? Are there any other approaches I should look into? I'm very new to JavaEE, I hope I'm not asking dumb questions.. Oh, the shame..! :-)
What I did to solve my problem was to get the product development team to add a new session bean in the main product that is injected with a entity manager and a getEntityManager method that the aaa.ear ejb can call.