You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by "Romain Manni-Bucau (JIRA)" <ji...@apache.org> on 2016/03/07 12:19:41 UTC

[jira] [Updated] (TOMEE-1547) Use application classloader for resources defined in resources.xml

     [ https://issues.apache.org/jira/browse/TOMEE-1547?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Romain Manni-Bucau updated TOMEE-1547:
--------------------------------------
    Fix Version/s:     (was: 7.0.0-M3)
                   7.0.0-M4

> Use application classloader for resources defined in resources.xml
> ------------------------------------------------------------------
>
>                 Key: TOMEE-1547
>                 URL: https://issues.apache.org/jira/browse/TOMEE-1547
>             Project: TomEE
>          Issue Type: Improvement
>    Affects Versions: 1.7.1
>            Reporter: Jonathan Gallimore
>            Assignee: Jonathan Gallimore
>             Fix For: 1.7.4, 7.0.0-M4
>
>
> 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++) {
>                     urls[i] = serviceInfo.classpath[i].toURL();
>                 }
>                 loader = new URLClassLoaderFirst(urls, loader);
>                 customLoader = true;
>             }
>         } catch (final MalformedURLException e) {
>             throw new OpenEJBException("Unable to create a classloader for " + serviceInfo.id, e);
>         }
>         Object service = serviceRecipe.create(loader);
>       



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)