-
1. Re: About JBoss5 classloader
alesj Jul 29, 2010 8:32 AM (in response to jnesta)1. During jboss starts, class A is visible to B, but B is not visible to A. Does this mean that they doesn't belong to the same domain (DefaultDomain)?
Yup, both should be in the same domain - DefaultDomain.
How can you tell B is not visible to A?
2. Does UCL(UnifiedClassLoader3) in http://community.jboss.org/wiki/JBossClassLoadingUseCases match BaseClassLoader?
The semantics should be pretty much the same, at least that's what we wanted to support. :-)
-
2. Re: About JBoss5 classloader
jnesta Jul 29, 2010 11:03 PM (in response to alesj)Hi Ales,
Thank you very much.
Yes, both are in DefaultDomain. I see this in jmx-console.
Yup, both should be in the same domain - DefaultDomain.
How can you tell B is not visible to A?
A.java snippet
public class A {
public void start() {
System.out.println(this.getClass()..getClassLoader());
// and print parent and ancestor classloader
System.out.println(new B());
}
}When JBoss starts, NoClassDefFoundError is thrown out.
According to my understanding, two BaseClassLoader instances for a.beans and b.beans share a same class repository (DefaultDomain). If B is visible to A, then BaseClassLoader for a.beans can load class B.
The scenario contains servel steps:
1. BaseClassLoaders are registered to class repository (DefaultDomain)
2. BaseClassLoader for a.beans trys to load class B, and it trys from class repository, but it can't find.
3. Because BaseClassLoader for b.beans declares that it can load class B
4. Class repository delegates BaseClassLoader for b.beans to load class BBut this doesn't explain why NoClassDefFoundError happens.
Another question:
When is contextClassLoader of current thread set in JBoss5?Regards,
Nesta -
3. Re: About JBoss5 classloader
alesj Jul 30, 2010 3:56 AM (in response to jnesta)But this doesn't explain why NoClassDefFoundError happens.
OK, I see your problem.
The reason why B is not found in A is b/c of the way we deploy deployers/ vs. deploy.
ProfileService in AS deploys different parts of AS libs in different phases.
(1) bootstrap phase -- conf/bootstrap/ dir
(2) deployers/
(3) deploy/
So, at the time your A class in deployers/a.jar is deployed, B class in deploy/b.jar is not yet deployed,
hence no matching classloader.
If you would lazy load A, only checking B when you know it's gonna be available, it would be OK.
When is contextClassLoader of current thread set in JBoss5?
Different sub-systems set if differently.
If you're asking about deployes/VDF, then the answer is DeployerWrapper class.