5 Replies Latest reply on Jun 3, 2015 11:42 AM by zamrokk

    How to use common libraries used by different modules in Wildfly?

    giofyxle

      Hallo!

       

      We have an EAR and a resource adapter that use the some same libraries. When we install them to Wildfly we give these libraries to each of them.

      And when we try to access the resource adapter from the EAR we experience a Class-Cast-Exception like:

       

      HttpEisFactory cannot be casted into HttpEisFactory. (where HttpEisFactory is a class of one of these libraries used by EAR and resource adapter)

       

      We guess this is because resource adapter and EAR are two separated independent modules inside Wildfly and therefore use separated Class-Loaders.

       

      Therefore we would like to define some "common libraries" that are deployed only once in Wildfly but can be used by different modules. If we moved our libs to this common libraries, we would expect not to see this Class-Cast-Exception.

       

       

      How do I define such "common libraries" in Wildfly?

       

       

      Thanks

       

      Gio

        • 1. Re: How to use common libraries used by different modules in Wildfly?
          wdfink

          You need to create a module for the common libraries and add a module dependency to your application.

          See Class Loading in WildFly , a module is simple to create, see this example Data Source Configuration in AS 7 that should help.

          • 2. Re: How to use common libraries used by different modules in Wildfly?
            lafr

            Or put the files in only the resource adapter for instance and create a dependency from ear to rar:

            <ear earfile="${BIN}/${pre-stage.ear.name}" appxml="${etc.dir}/application.xml">          
                    <fileset dir="${build.deploy.dir}" includes="ejb-entity.jar"/>                        
                    <fileset dir="${build.deploy.dir}" includes="ejb-session-*.jar"/>                     
                    <fileset dir="${build.deploy.dir}" includes="ws-*.war"/>                              
                    <manifest>                                                                            
                        <attribute name="Dependencies" value="deployment.controller.rar, deployment.XADisk.rar"/>
                    </manifest>                                                                           
            </ear>                                                                                     
            • 3. Re: How to use common libraries used by different modules in Wildfly?
              giofyxle

              Hallo Frank, hallo Wolf-Dieter

               

              Thank You for your answers!

              Frank's suggestion seams to be less complicated than Wolf-Dieter's. For this reason I want to check this first.

               

              But: Where do you configure this dependency? You give an example part of an xml-File. To which xml-files does it belong?

               

              Thank You,

              Gio

              • 4. Re: How to use common libraries used by different modules in Wildfly?
                lafr

                I'm using ant for build, packaging and deploy. The xml above is part of my build,xml.

                At the and you have to have something like this in your ear's META-INF/MANIFEST.MF: Dependencies: deployment.controller.rar, deployment.XADisk.rar

                • 5. Re: How to use common libraries used by different modules in Wildfly?
                  zamrokk

                  Another solution is what i did if you have a EAR and a RAR of Xadisk that you want to deploy

                   

                  Using maven :

                  - declare xadisk.jar as provided on ejb, war etc ...

                  - use a project connector including only ra.xml (ironjacamar.xml if u need it) and xadisk.jar as provided

                  - in the ear file, import the shared xadisk.jar that is used both with rar and ejb/war projects

                   

                  As it you have only 1 version of the xadisk classes and all is deployed at same time

                   

                  i passed 3 days on this set up to understand -__-'