Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
1.7.1
-
None
-
None
Description
Resources can be defined in applications using META-INF/resources.xml. This is a useful feature, but because resources are created very early on in deployment the final classloader for the application is not available.
I know I can manually specify a specific jar or classpath, but I specifically want the resources I define to be loaded using the same classpath the application uses.
So, for example, if I have an EJB jar in an EAR, and the EJB jar contains a POJO called HelloBean, the following should load the resource from the application classloader:
<Resources>
<Resource id="Hello" type="org.superbiz.HelloBean">
property1 value1
property2 value2
</Resource>
</Resources>
Currently this fails with a class not found error, due to the following in org.apache.openejb.assembler.classic.Assembler.createResource(ResourceInfo):
ClassLoader loader = Thread.currentThread().getContextClassLoader();
boolean customLoader = false;
try {
if (serviceInfo.classpath != null && serviceInfo.classpath.length > 0) {
final URL[] urls = new URL[serviceInfo.classpath.length];
for (int i = 0; i < serviceInfo.classpath.length; i++)
loader = new URLClassLoaderFirst(urls, loader);
customLoader = true;
}
} catch (final MalformedURLException e)
Object service = serviceRecipe.create(loader);