[jboss-user] [EJB3] - Reload classloader for bean?

Aleksander Bai do-not-reply at jboss.com
Fri Nov 5 10:08:09 EDT 2010

Aleksander Bai [http://community.jboss.org/people/aleksab] created the discussion

"Reload classloader for bean?"

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


hope somebody can help me with this. I've search for forums, but haven't gotten a clear answer.

This is my scenario (using JBoss 5.1 JDK6):
I have some a service bean which is bundled in a contained jar file. This bean is deployed to the jboss server and works fine. Let's call this bean A.
In addition i have another (stateless) bean (bean B) which is deployed to the same server. Bean b looks bean A and uses some of it's methods. This works fine.

My problem arise when i deploy a new version of bean A. Note that the (exposed) interface has not changed, but some internal classes might have. The problem then arise when bean B tries to lookup bean A again. The lookup works fine, but when casting to the interface i get the famous: ClassCastException: $Proxy<nn> can not be casted to ...

I understand WHY this happens, since the class definition is a combination of actual class + classloader. And the remedy to the problem is easy, just redeploy bean b and it works again. Howver, it would be nice to do this WITHOUT redeploying. Is that possible? Any suggestions?

My initial thought was that i might get the CL for bean b to reload itself, but i haven't found anything about that in jboss. Another thing might be to "terminate" all current instances of bean b, so the next call to bean b will create a new instance with a new CL and thus avoid the problem. Is there any way i can do that?

Thanks for all ideas and replies

Reply to this message by going to Community

Start a new discussion in EJB3 at Community

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

More information about the jboss-user mailing list