2 Replies Latest reply on Oct 7, 2009 1:13 PM by s3filho

    EJB with WAR Classloader

    s3filho

      Hello Everyone,

      I've done some tests and realized that EJBs and Web applications always run on different Classloaders
      A static property of a class that an EJB access doesn't necessary have the same value of the same static property of the same class that a Web applications access.
      I was expecting this when we do separated deploys but I've put them together inside the same EAR and the Classloaders keep different.

      Is there anyway of forcing that some EJBs and some Web applications share the same Classloaders?
      If not, is there another way of an EJB access a static property inside the Web applications?

      Thank you very much.

        • 1. Re: EJB with WAR Classloader
          jaikiran

          As per the spec, the .war has its own isolated classloader. However if you want to change that behaviour then follow this http://www.jboss.org/community/wiki/useJBossWebClassLoaderinJBoss5

          If not, is there another way of an EJB access a static property inside the Web applications?


          If that class with the static field is meant for both war and EJB jar, then why not package that in a separate jar file and place it in EAR/lib folder so that it's available to both the components and loaded by the same classloader.

          • 2. Re: EJB with WAR Classloader
            s3filho

            Thank you,

            Creating the jboss-classloading.xml file worked fine but what you said made me think better and it really was my mistake.
            The class I was using was placed in both blaces (war an EJB jar) so it was loaded twice.

            Thank's again