I'm trying to set up my application to have its own class loading scope. I also want to enable Java2 class loading delegation. So I add the following to my jboss-app.xml:
This sometimes work and sometimes doesn't. Consider a class A that is available both from my EAR file and a service archive (that uses the default class repository). If A has already been loaded from the service archive when my application needs A, the loaded version is used. Otherwise, it is loaded fresh from my EAR file instead of the service archive, contradicting java2ParentDelegaton=true.
Digging into the source code, I find that indeed the getPackageClassLoaders() method of HeirarchicalLoaderRepository3 is putting its own class loaders first, regardless of java2ParentDelegaton setting. Is this a bug or my misunderstanding? Note that loadClassFromCache() consults the parent repository first if java2ParentDelegaton=true, so that if the class is already loaded by the parent, delegation works.
Thanks for any help and advice.