1 Reply Latest reply on Dec 1, 2013 8:40 AM by wdfink

    class loading order for jars in war

    sigma.wschung

      I am using a war file generated by a third party tool. In the generated war file, there is an generated jar file, says rd.jar,  the tool generates a class that has the same qualified name as another class, say, p.Lg,  in a fourth party jar file, says p.jar. According to the creator of the third party tool, this is the only way he can override the behavior of the fourth party library. He claims that his tool works because container usually load the jars in a war file in alphabetical order. This does not works in JBoss 7, not out of the box at least.

       

      In order to get the generated file to work in JBoss 7, I need to be able to control the order of the jar files(i.e. rd.jar before p.jar) in the class loading search path. I would like to know how much control one has in the class loading order of different jar files inside a war file. For example, does JBoss respect the order of Class-Path field in the manifest of the war file?

        • 1. Re: class loading order for jars in war
          wdfink

          I don't think that this will work consistent for several implementations. It depends on the classloader behaviour.

          A chance might be to have the fourth party lib need to be extracted from the war and packed in a surrounding EAR or you create a module and set a dependency. In that case the third party lib inside the war will have priority.

          That will work reliable in any container I think.

           

          See Class Loading in AS7