0 Replies Latest reply on Jan 22, 2013 11:59 AM by Paul Saulue

    Packaging strategy, hot deployment and classloaders

    Paul Saulue Newbie

      Hi everybody,

      I'm working with Jboss AS 6 + GateIn 3.2.0 Final.


      I have a project with several EJB3s (stateless and one ejb entity) all packaged within a single ear.

      Besides, I have a portlet packaged in a WAR.


      Here is my problem and my interpretation, correct me if I'm wrong:

      I can deploy the EAR first successfully and my EJBs are registered with no problem. Then I can deploy the WAR which find the entity classes in the ejb. Here, everything is fine, my app works perfectlty. No Problems.


      But now, if I undeploy the ear and redeploy it, a ClassCastException arises on the same class: xxx.User cannot be cast to xxx.User. This problem is solved by redeploying the war.

      After some researches, I found that each ear has his own classloader and that classes in ear are visible to webapps (if classloader is not isolated, which is not my case).

      So my guess is that the classloader used to load the ejb the first time it's deployed isn't the same than the second time. So my webapp is trying to cast a class with the same name, but a different classloader, which leads to the ClassCastException. Right?


      Now, if I'm right, I've some questions:

      1/ Am I doing something wrong?

      2/ Is it possible to package all my EJBs and WAR in a way that I could do some changes in my EJBs (deploy/undeploy) without the need of redeploying the war each time? I tried classloader isolation but didn't manage to fix my problem, but get tones of other exceptions.

      3/ Assuming that I package everything in the ear, is it possible to trigger the redeployment of only the war but not the whole ear, or only one ejb?


      Off topic:

      3/ Is it normal that deploying my ejb is almost instant whereas deploying a war take a lot of time to achieve (~1mn30)?


      I hope I've been clear enough,

      Thanks in advance for help and explanations