2

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?

Ralph
  • 4,500
  • 9
  • 48
  • 87

1 Answers1

5

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.

Andy Guibert
  • 41,446
  • 8
  • 38
  • 61
  • Thanks for the good explanation. My goal is to make tweaks to active files. So I understood that I should deploy a singe .war file and than test my tweaks within the app/expanded/myapp folder. But so I need 'autoExpand=true' - right? The liberty dev mode is not a solution for me because I use a complex docker based setup with docker-compose. And the liberty dev mode starts only a single server. – Ralph Mar 26 '20 at 12:22
  • Ok now it works for all files. To enable the hot-deploy also for single JSF files the context-param 'javax.faces.FACELETS_REFRESH_PERIOD' should be set to 1. Otherwise the default value of -1 will prevent openLiberty to reflect changes of this kind of files! – Ralph Mar 26 '20 at 17:45
  • Andy, how about dev mode for non maven projects? Is it possible without copying expanded app to apps folder? – Gas Mar 27 '20 at 02:33
  • Maybe there is a way to tell the OpenLiberty maven plugin that the active files are located on a different location - in my case a docker volume pointing into my IDE. – Ralph Mar 27 '20 at 08:35
  • 1
    @Gas yes, if you don't put `autoExpand="true"` in your config then you can just put a directory of files for your application in the normal location instead of a single .war file. For example put your compiled app files under `./apps/myapplication.war/WEB-INF/classes/` – Andy Guibert Mar 27 '20 at 13:03