5 Replies Latest reply on Jan 21, 2009 11:42 AM by hamtho2

    Deploying multiple ears with

      Hi,

      I am currently facing the following problem:
      I need to configure my ear for multiple environments. Therefor I used the hibernate.properties in the root folder of the ear to configure my persistence-layer. This works perfectly so far, because Hibernate finds the properties through it´s Environment and loads them.

      BUT:

      if I now deploy another ear, holding a hibernate.properties for configuring the second application, the hibernate.properties are simply ignored and - even more - the hibernate.properties from the first deployment are used for my second deployment as well.

      While looking in the Hibernate source code I saw that the corresponding variable is defined as a static variable.

      private static final Properties GLOBAL_PROPERTIES;


      It seems as if this class will be loaded only once and the first deployment wins. I already tried to work with isolated classloaders and set the value for
      <attribute name="Isolated">true</attribute>
      


      in the ear-deployer.xml to false. But this didn´t make any difference.

      Does anyone has an idea how to use multiple hibernate.properties or any other way to handle multiple configurations for the persistence-layer?

      Thanks for any input

      Thomas

        • 1. Re: Deploying multiple ears with
          sanjeevkoppal

          Try setting UseJBossWebLoader=true in
          server\default\deploy\jboss-web.deployer\META-INF\jboss-service.xml


          • 2. Re: Deploying multiple ears with
            sanjeevkoppal

            Also, try to remove the hibernate jars from Jboss default library if you are having hibernate jars in ur ear..

            • 3. Re: Deploying multiple ears with

              Thanks for the idea.

              I´m currently using the hibernate jars from the /server/default/lib directory and no further jars are included in my ear.

              Unfortunatley the "UseJBossWebLoader" does not have any effect on this.
              But maybe this is because it is not an web application, but an ear containing one jar with Entity-classes and one jar with the server-ejb3-sessionbeans.

              Any other idea?

              Thomas

              • 4. Re: Deploying multiple ears with
                jaikiran

                 

                It seems as if this class will be loaded only once and the first deployment wins.


                In such cases, you will have to load that class again through a separate classloader. Something along these lines:

                * Package all the relevant and correct version of hibernate jar files with your application ears. You can place them in EAR/lib folder. Each ear should package these jars.

                * Package the hibernate.properties in each EAR. Place that file wherever they are now (at the root of EAR?)

                * Configure scoped classloading for each of the EAR through jboss-app.xml. https://www.jboss.org/community/docs/DOC-9288. Ensure that the jboss-app.xml contains a unique loader-repository name for each of the ear.


                • 5. Re: Deploying multiple ears with

                  @jaikiran

                  Thanks for your answer.
                  It was a little bit circumstantial, as there are some struggles with the current maven ear plugin, but that was finally the solution!!!!
                  Now it works!! Thanks!

                  Thomas