Apr 15th, 2009, 01:33 AM
Pitchfork with multiple EJB modules in the same EAR
We're currently looking into Pitchfork to replace our legacy EJB2.1 wrappers for Spring services (custom framework).
Pitchfork works great in the sense that we just have to annotate our services to use EJB3,
and can leverage our existing Spring contexts to configure the services.
Our target platform is Weblogic 10.3
However, we are experiences some problems in the following 2 cases:
1. multiple EJBs in the same EAR.
|---> EJB module 1 (/META-INF/spring-ejb-jar.xml)
|---> EJB module 2 (/META-INF/spring-ejb-jar.xml)
Due to fact that both EJB modules share the same classloader, Pitchfork cannot pick up individual /META-INF/spring-ejb-jar.xml files
for each EJB module. Pitchfork will always load the same config file (in this case the one from EJB module 1),
meaning it will only work for this particular EJB module in the EAR. EJB module 2 will pick up the wrong spring-ejb-jar.xml, causing the enrichment to fail (Pitchfork enricher cannot match the EJB names with the spring bean name).
This is standard out-of-the-box weblogic classloader behavior.
When configuring the classLoaders in weblogic to achieve classloader isolation between EJB modules, I noticed that Pitchfork ignores this
by using the wrong classloader / spring resourcelocator to load the bean definitions and create the beans.
Although the WLSBootstrap is provided with the correct classloader (according to the javadocs the classloader that the components managed by this instance will be created in.),
the WLSBootstrap doesn't do anything with it. Despite this bug (?), although it would solve issue nr 1, it wouldn't solve the following issue we're facing
2. Single EJB module & JAR file(s) in APP-INF/lib containing a /META-INF/spring-ejb-jar.xml
|---> EJB module (/META-INF/spring-ejb-jar.xml)
|---> APP-INF/lib/pojoservice.jar (/META-INF/spring-ejb-jar.xml)
Our services can either be deployed remotely as EJBs, or locally in POJO mode.
This means that a POJO service can also be packaged as a JAR file in an EAR file.
When this is the case, and the JAR file happens to contain a /META-INF/spring-ejb-jar.xml, Pitchfork will always load the one
from APP-INF/lib instead of the one from the EJB (standard classloader behavior)
(as there is no prefer-ejb-classes to have a child-first delegation model for EJB modules to my knowledge, APP-INF/lib will always be the parent).
Is there a solution that might solve the issues above ?
I was looking into the possibility of customizing the pitchfork resource loading (spring-ejb-jar.xml).
I would like to have some way of controlling the name of the resource that each EJB modules uses, in order to use spring-service1-ejb-jar.xml, spring-service1-ejb-jar.xml, .... instead of the default spring-ejb-jar.xml.
However, I don't think that Pitchfork is meant to be extended by developers, and as such didn't find a clean way to do it
without overriding the Pitchfork classes.
|---> EJB module 1 (/META-INF/spring-service1-ejb-jar.xml)
|---> EJB module 2 (/META-INF/spring-service2-ejb-jar.xml)
Tags for this Thread