[jboss-user] [JBoss Microcontainer] - About JBoss5 classloader

nesta fdb do-not-reply at jboss.com
Thu Jul 29 23:02:36 EDT 2010


nesta fdb [http://community.jboss.org/people/jnesta] replied to the discussion

"About JBoss5 classloader"

To view the discussion, visit: http://community.jboss.org/message/555092#555092

--------------------------------------------------------------
Hi Ales,

Thank you very much.
> 
> 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 B

But this doesn't explain why NoClassDefFoundError happens.

Another question:
When is contextClassLoader of current thread set in JBoss5?

Regards,
Nesta

--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/555092#555092]

Start a new discussion in JBoss Microcontainer at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2114]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20100729/c8494fab/attachment.html 


More information about the jboss-user mailing list