7 Replies Latest reply on Aug 2, 2015 7:41 PM by James Livingston

    How to apply patches to deployed application?

    Prasad Amte Newbie

      Suppose we deploy the application on Wildfly. Later on , if there is a patch to be applied to the deployed application. How do we apply this patch? Can we declare some folder as patch folder and the classes in the patch.jar will override the ones in deployed application?

      Please provide a pointer.

        • 1. Re: How to apply patches to deployed application?
          Tomaz Cerar Master

          look/search docs/google for "deployment overlays"

          • 2. Re: How to apply patches to deployed application?
            Prasad Amte Newbie

            Hello Tomaz,

            1) Is the deployment overlay related configuration saved somewhere OR every time when I start the application,  I need to execute the "

             

            deployment-overlay add ..." command ?

            I didnot find much documentation about this apart from this link.

            Deployment Overlays - WildFly 8 - Project Documentation Editor

             

            2) Suppose I have  deployed "abc.war". I have a xyz.jar in the WEB-INF/lib folder of that war. I want to override only certain classes in the xyz.jar so I can add xyz_overriden.jar as a part of overlay, which contains only say 4 classes.

            Now the overlay mechanism will consider only the overriden.jar(by discarding xyz.jar) or it will first load classes from overridden.jar and then it will load xyz.jar so that overridden classes are given higher priority.

             

            3) I want to add a structure under WEB-INF/classes, e.g like com/../myclass and I expect that this structure should go below WEB-INF/classes. How do I achieve this through overlay? There is no base file/folder in deployed war  which will be overridden by this structure.

             

            4) Also, can we overlay the entire folder?

             

            Please provide your suggestions.

            • 3. Re: How to apply patches to deployed application?
              James Livingston Apprentice

              1) It's stored as part of the server profile (along with the deployments themselves).

               

              2) No, you can only override whole files.  I haven't tried to see what happens if your WAR contains a jar, but the overlay has a directory of the same name instead. If that works, I'm not sure if it's reliable. There is no way to provide an ordering on WEB-INF/lib jars or WEB-INF/classes.

               

              3) You put WEB-INF/classes/com/.../myclass in the overlay

               

              4) What do you mean overlay the entire folder? You can add as may things to the overlay as you want

              • 4. Re: How to apply patches to deployed application?
                Prasad Amte Newbie

                Thanks James for update.

                 

                1) It's stored as part of the server profile (along with the deployments themselves).

                [Prasad]:- Any file location/filename where it is stored?


                2) Typically when we apply patches, we deliver only the changed class files? How this patch is applied then? Or do I have to package the changed files alongwith the unchanged files in the jar ?


                3)You put WEB-INF/classes/com/.../myclass in the overlay.

                [Prasad]:- For this what source mapping shall I give? or shall I give empty folder as a source location which I want to override?


                4) Entire folder means, supposed I already have WEB-INT/classes/com/test and now as an overlay can I give test folder which has it's own folder structure under it .

                Please suggest.


                • 5. Re: How to apply patches to deployed application?
                  James Livingston Apprentice

                  The overlay data is stored somewhere under the data/contents directory, exactly where is an implementation detail of the server (but it's named by the sha1 hash of the content).

                   

                  What are you currently using to do patches with only the changed classes?

                   

                   

                  Using the example from the docs:

                  deployment-overlay add --name=myOverlay --content=/WEB-INF/web.xml=/myFiles/myWeb.xml,/WEB-INF/ejb-jar.xml=/myFiles/myEjbJar.xml --deployments=test.war,*-admin.war --redeploy-affected

                  This means it picks up the file /myFiles/myWeb.xml from disk, and adds it to the overlay as WEB-INF/web.xml, and does the same with the ejb jar file. Then the overlay (containing /WEB-INF/web.xml and /WEB-INF/ejb-jar.xml) is applied to test.war and all deployments ending in -admin.war, and those deployments redeployed so it takes effect

                   

                  So you need to tell it what you want to replace, and the file on the filesystem to replace it with. You could have WEB-INF/classes/com/test/MyClass.class=/some/path/MyClass.class

                  • 6. Re: How to apply patches to deployed application?
                    Prasad Amte Newbie

                    We are moving to JBoss and I am trying to find out how do I apply patches to my deployed application. It seems deployment overlay is one of the options. Please let me know if you are aware of any other option.

                     

                    In general,  we prepare a patch.jar which has only the changed classes and changed classes are given higher precedence so that the code from those classes are used.

                     

                    In my case war file has a "xyz.jar" file and I want to override only certain classes from it. So I prepared a patch.jar having only few classes. I excecuted the command as per doc (which you have also refererd to) but it seems xyz.jar is completely ignored and only patch.jar is considered. Because it  is not finding other supporting classes from the jar and it is giving exception. Ideally the only classes from patch.jar should be overriden and the rest of the classes from xyz.jar should be loaded.

                     

                    What do we do if we want to add a completely new jar, in short I want to add new classes for which there is no existing deployed classes in war, how do we achieve this using overlay?,

                    • 7. Re: How to apply patches to deployed application?
                      James Livingston Apprentice

                      Since you are moving to JBoss, what solution are you using on your current app server?

                       

                      So I prepared a patch.jar having only few classes. I excecuted the command as per doc (which you have also refererd to) but it seems xyz.jar is completely ignored and only patch.jar is considered

                      You are using "--content=/WEB-INF/lib/xyz.jar=/myFiles/patch.jar" ? Yes, it will do that because the overlay mechanism replaces files. There is no way to make it merge the jars - it would be quite complex, since what happens if code tried to load the jar as a byte stream? Class loading is not the only thing that cares about class files in jars in WEB-INF/lib, some frameworks read the jars to do annotation scanning for example.

                       

                      If you want to add a new jar with new classes, use the above with the deployment file name being a new WEB-INF/lib/*.jar name that does not already exist.