1

I have Open liberty server installed in eclipse. Any changes to .html , .java or server.xml files are picked as soon I save the file.

However changes to .xhtml files are not picked in the same dynamic way. I have to do a runas on server to see the changes.

How to set Open Liberty to pick up changes using the hot reload for .xhtml files ?

RocknRolla
  • 21
  • 1
  • What kind of project are you using ? Is this a Maven or Gradle project ? Using the liberty maven/gradle plugins ? – Scott Kurz Feb 03 '21 at 13:23

1 Answers1

0

This question is already answered here: JSF and automatic reload of xhtml files

However, as the question in the link above is specific to the WebLogic app server and there are several comments on what works on what app server (Glassfish, JBoss), but without mentioning Open Liberty, I throw in my two cents here:

For hot reload / dynamic update of a xhtml file, the xhtml file must be copied to the target (obviously) and the xhtml file must be recompiled.

In case of the OP, it seems that the second condition is not met.

In web.xml set the context parameter javax.faces.PROJECT_STAGE to Development with the following snippet:

  <context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
  </context-param>

JSF 2.x caches xhtml pages (that is, the compiled xhtml pages). Setting javax.faces.PROJECT_STAGE to DEVELOPMENT disables the caching of xhtml pages, thus any changes an a xhtml file take effect immediately.

If you work with the Liberty Maven Plugin and start the server with mvn liberty:dev, any changes of xhtml files are picked up and the changed files are copied to target/<your-app-name>/<path-to-xhtml-file>

If you run Open Liberty from an IDE like Eclipse, Intellij or Netbeans, you have to make sure that changed xhtml files are copied to the target.

In Open Liberty, you do not have to fiddle with javax.faces.REFRESH_PERIOD, as it seems to be the case with some other app servers (see link above). If for any reason you have to do so, set javax.faces.REFRESH_PERIOD to 0 or a low integer value.

Rudolf Held
  • 503
  • 3
  • 7
  • If you're using the latest version of OpenLibery and JSF (now Jakarta Faces), then the param name becomes `jakarta.faces.PROJECT_STAGE`. – hrs Sep 17 '22 at 20:17