[jboss-user] [EJB 3.0] - Why does Thread.getContextClassLoader in an stateless bean r

yanfengzhang do-not-reply at jboss.com
Wed Jan 2 05:02:02 EST 2008


I'm using JBoss AS 4.2.2.

I worked out an ear with a war and a ejb-jar and several library jars in it. Some more information:
1. there is a very simple servlet in the war which do nothing more than retrieving some messages from the back-end stateless session beans and showing them in the browser.
2. In the ejb-jar, I have several stateless beans and an interceptor class which has a method for @PostConstruct. In all the beans and the interceptor, I added something like the following:
 
  | System.out.println("Thread class loader: "+Thread.currentThread().getContextClassLoader());
  | System.out.println("local class loader: " + this.getClass().getClassLoader());
  | 

The output is somehow amazing to me: the thread class loader is always WebappClassLoader for the stateless beans and interceptor! and the "local class loader" is UnifiedClassLoader3 in stateless session beans and interceptors and in servlet "WebappClassLoader".

Should not the Thread.currentThread().getContextClassLoader() in stateless beans and interceptors return the same class loader as this.getClass().getClassLoader() (that is UnifiedClassLoader3 instead of WebappClassLoader)? Is that a bug?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4116331#4116331

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4116331



More information about the jboss-user mailing list