Search code examples
open-liberty

How to activate hot-deployment in OpenLiberty for single files?


I have installed openLiberty 20.0.0 and I want to activate hotdeployment. For that I added the applicationMonitor tag into the server.xml

<applicationMonitor updateTrigger="polled" pollingRate="500ms"
                dropins="dropins" dropinsEnabled="true"/>

But these seems to be the defaults already. So maybe I can leave it.

I also added the autoExpand feature

<applicationManager autoExpand="true" />

Now when I deploy a .war file into the dropins folder the application is automatically recognized by openLiberty and deployed immediately. This is fine so far.

But as I understood, also a hotdeploy of single source files (e.g. .html, .xhtml.) should be recognized and updated in my running application without the need of a full redeployment.

If I change for example a single jsf file within the application folder

./dropins/myapplication.war/my-page.jsf

nothing happens. What did I miss to let OpenLiberty also recognize this minor file changes?


Solution

  • Simple answer:

    remove <applicationManager autoExpand="true" /> and things will work how you expect.


    Longer answer:

    If you have <applicationManager autoExpand="true" /> in your server.xml configuration then the application will be automatically expanded into a new folder at ${server.config.dir}/apps/expanded/APP_NAME/

    So when you run application you will have a file layout like this:

    ./server.xml
    ./dropins/myapplication.war
    ./apps/expanded/myapplication.war/my-page.jsf
    ./apps/expanded/myapplication.war/WEB-INF/classes/com/foo/SomeAppClass.class
    

    The "active" set of files will be the files under the apps/expanded/ folder which you can then hot-update. This approach is useful if you want to deploy a single .war file and then make tweaks to it after you deploy it, such as in dev mode. However, be cautious about directly making changes to the expanded folder because it can be wiped away if a server is restarted and the app is re-expanded.


    Normally users don't need to be aware of the details of app expansion or hot-updates because it's all taken care of if you use Liberty dev mode. If you haven't tired that out already, I'd highly recommend it.