OpenLiberty / ci.maven

Maven plugins for managing Liberty profile servers #devops
Apache License 2.0
130 stars 91 forks source link

Copying server.xml from src in Dockerfile and adding feature in server.xml causes feature not found #1070

Open ericglau opened 3 years ago

ericglau commented 3 years ago

Using the latest SNAPSHOT of liberty-maven-plugin,

  1. Use the coffee-shop folder from https://github.com/sdaschner/coffee-testing/tree/liberty-dev
  2. Change the FROM line to: FROM openliberty/open-liberty:kernel-slim-java15-openj9-ubi
  3. Add RUN features.sh at the bottom of the file
  4. Remove <feature>mpHealth-2.0</feature> from server.xml
  5. Run mvn liberty:devc
  6. Once the server is up, add <feature>mpHealth-2.0</feature> to server.xml
  7. Liberty picks up the change before the features are finished installing. This causes Liberty to give an error that the feature is not found, and does not enable the feature after the feature is actually installed.

The workaround is to use the full image instead of kernel-slim

Original error below:

[DEBUG] Plugin listed feature: mphealth-2.0
[INFO] Parsing the server file /Users/eric/git/coffee-testing/coffee-shop/target/liberty/wlp/usr/servers/defaultServer/configDropins/defaults/postgres-driver.xml for features and includes.
[INFO] Parsing the server file /Users/eric/git/coffee-testing/coffee-shop/target/liberty/wlp/usr/servers/defaultServer/server.xml for features and includes.
[INFO] Parsing the server file /Users/eric/git/coffee-testing/coffee-shop/target/liberty/wlp/usr/servers/defaultServer/configDropins/overrides/dev-mode-config.xml for features and includes.
[INFO] Installing features [jsonb-1.0, mpconfig-1.3, jaxb-2.2, cdi-2.0, jsonp-1.1, beanvalidation-2.0, jpa-2.2, ejblite-3.2, jaxrsclient-2.1, mphealth-2.0, jaxrs-2.1] on container liberty-dev
[DEBUG] execDocker, timeout=600, cmd=docker exec -e FEATURE_LOCAL_REPO=/devmode-maven-cache liberty-dev /liberty/bin/featureUtility installFeature jsonb-1.0 mpconfig-1.3 jaxb-2.2 cdi-2.0 jsonp-1.1 beanvalidation-2.0 jpa-2.2 ejblite-3.2 jaxrsclient-2.1 mphealth-2.0 jaxrs-2.1 --acceptLicense
[INFO] [AUDIT   ] CWWKG0016I: Starting server configuration update.
[INFO] [AUDIT   ] CWWKG0093A: Processing configuration drop-ins resource: /opt/ol/wlp/usr/servers/defaultServer/configDropins/defaults/keystore.xml
[INFO] [AUDIT   ] CWWKG0093A: Processing configuration drop-ins resource: /opt/ol/wlp/usr/servers/defaultServer/configDropins/defaults/open-default-port.xml
[INFO] [AUDIT   ] CWWKG0093A: Processing configuration drop-ins resource: /opt/ol/wlp/usr/servers/defaultServer/configDropins/defaults/postgres-driver.xml
[INFO] [AUDIT   ] CWWKG0093A: Processing configuration drop-ins resource: /opt/ol/wlp/usr/servers/defaultServer/configDropins/overrides/dev-mode-config.xml
[ERROR] [ERROR   ] CWWKF0001E: A feature definition could not be found for mphealth-2.0
[INFO] [AUDIT   ] CWWKG0017I: The server configuration was successfully updated in 0.156 seconds.
[INFO] [AUDIT   ] CWWKF0008I: Feature update completed in 0.130 seconds.
[DEBUG]  Initializing ... <---------------------> 0.00% Resolving remote features. This process might take several minutes to complete. <====-----------------> 15.00% Preparing assets for installation. This process might take several minutes to complete. <======---------------> 25.00% Starting installation ... <============---------> 60.00% Successfully installed feature json-1.0. <==============-------> 62.33% <==============-------> 64.67% <==============-------> 67.00% Successfully installed feature mpHealth-2.0. <==============-------> 69.33% <================-----> 71.67% Successfully installed feature servlet-3.1. <================-----> 74.00% <================-----> 76.33% <================-----> 78.67% <================-----> 81.00% <==================---> 83.33% Successfully installed feature cdi-1.2. <==================---> 85.67% <==================---> 88.00% <==================---> 90.33% <====================-> 92.67% <====================-> 95.00% All features were successfully installed. <====================-> 95.00% <====================-> 100.00%  Start product validation... Product validation completed successfully. 
[DEBUG] (org.codehaus.mojo.pluginsupport.logging.Logging) Resetting
[DEBUG] Successfully deleted liberty:dev temporary configuration folder
[INFO] Copied file: /Users/eric/git/coffee-testing/coffee-shop/src/main/liberty/config/server.xml to: /Users/eric/git/coffee-testing/coffee-shop/target/liberty/wlp/usr/servers/defaultServer/server.xml
TrevCraw commented 3 years ago

Another workaround is to COPY the server.xml located at target/liberty/wlp/usr/servers/defaultServer in the Dockerfile instead of the server.xml located in the src/main/liberty/config folder.

TrevCraw commented 2 years ago

I think the following is the reason for Liberty picking up the server configuration change before features are done installing and dev mode copies the src file to target:

When the Dockerfile contains a line to "COPY" the src file to target, the src file is then mounted to the target dir inside the container for devc. Whenever there is a change to the local src file, that same change is occurring inside the target dir on the container. This change inside the container's target dir triggers Liberty to update the server configuration immediately and not when dev mode eventually copies the file from src to target.