2 Replies Latest reply on Nov 10, 2010 10:46 AM by Jaikiran Pai

    Reload classloader for bean?

    Aleksander Bai Newbie



      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