I have a main app EJB and a war in a package. The main_app.ejb holds the persistenceContext
I now have a library that is used in multiple other applications on other webServices (with a similar built up but different persistence configurations on different web servers).
This one needs the persitenceContext to function. We previously had each class in the lib extended in the main EJB with the manager as a member. This works but you have a lot of manual handling since each class needs to be extended.
To understand my problem let me scetch teh following dynamic:
app.ear
\ lib/dependecy.jar (needs persistence context)
\ main_app.ejb (has persistence context | needs dependency.jar)
\ main_app.war
\ module.ejb
\ module.war
First approach:
The idea now is to include the library as it's own EJB and load it alongside the other EJB's and WAR's in the ear. The problem we face now is, since the main EJB is dependent on the lib, it seems to cannot find the EntityManager.
To understand my problem let me scetch teh following dynamic:
app.ear
\ dependecy.ejb (I transformed that into an ejb and loaded it alongside the others)
\ main_app.ejb (needs dependency.ejb)
\ main_app.war
\ persistence.ejb (extracted from the main_app.ejb w the META-INF/persistence.xml and a class implementing an interface for the EntityManager)
\ module.ejb
\ module.war
My first approach to solve this was to abstract the persistence into it's own EJB and then load that before the actual EJB which has the lib as a dependency. But this also does not seem to work.
I suspect the problem is that the dependency.ejb has no dependency from the persistence.ejb (and I cannot create one in the maven config, since i need this to work with the other servers as well, and they have different configurations.)
e.g. the dependency structure is:
main_app.ejb
/ \
dependency.ejb peristence.ejb
but persistence needs to be loaded before dependeny without me adding it to the actual dependencies.
btw I am using payara 5 atm.
is that possible?