OpenLiberty / ci.maven

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

dev mode in multimodule fails to restart server #1726

Closed andre-doherty closed 11 months ago

andre-doherty commented 1 year ago

hello,

Please let me report an issue regarding the liberty-maven-plugin.

When i try to restart a server configured in a submodule, using the 'r' key in the console, it usually fails as the plugin tries to add some features in the running server instance, which is killed as the features might be incompatible.

[INFO] Parsing the server file for features and includes: defaultServer/server.xml [INFO] plugin listed esa: [] [INFO] Installing features: [ejbLite-3.1, jsp-2.2, javaee-7.0, cdi-1.0, transportSecurity-1.0, jaxws-2.2, localConnector-1.0, jaxrs-1.1, jpa-2.0, beanValidation-1.0]

[ERROR] Could not restart the server. io.openliberty.tools.common.plugins.util.PluginExecutionException: org.apache.maven.plugin.MojoExecutionException: Error installing features for server defaultServer at io.openliberty.tools.maven.server.DevMojo$DevMojoUtil.libertyInstallFeature (DevMojo.java:408) at io.openliberty.tools.common.plugins.util.DevUtil.restartServer (DevUtil.java:1853) at io.openliberty.tools.common.plugins.util.DevUtil$HotkeyReader.readInput (DevUtil.java:2610) at io.openliberty.tools.common.plugins.util.DevUtil$HotkeyReader.run (DevUtil.java:2577) at java.lang.Thread.run (Thread.java:750) Caused by: org.apache.maven.plugin.MojoExecutionException: Error installing features for server defaultServer at io.openliberty.tools.maven.server.InstallFeatureMojo.doInstallFeatures (InstallFeatureMojo.java:77) at io.openliberty.tools.maven.server.InstallFeatureMojo.execute (InstallFeatureMojo.java:66) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126) at org.twdata.maven.mojoexecutor.MojoExecutor.executeMojo (MojoExecutor.java:120) at io.openliberty.tools.maven.server.StartDebugMojoSupport.runLibertyMojo (StartDebugMojoSupport.java:362) at io.openliberty.tools.maven.server.StartDebugMojoSupport.runLibertyMojoInstallFeature (StartDebugMojoSupport.java:347) at io.openliberty.tools.maven.server.DevMojo.runLibertyMojoInstallFeature (DevMojo.java:1870) at io.openliberty.tools.maven.server.DevMojo$DevMojoUtil.libertyInstallFeature (DevMojo.java:406) at io.openliberty.tools.common.plugins.util.DevUtil.restartServer (DevUtil.java:1853) at io.openliberty.tools.common.plugins.util.DevUtil$HotkeyReader.readInput (DevUtil.java:2610) at io.openliberty.tools.common.plugins.util.DevUtil$HotkeyReader.run (DevUtil.java:2577) at java.lang.Thread.run (Thread.java:750) Caused by: io.openliberty.tools.common.plugins.util.PluginExecutionException: A feature conflict error occurred while installing features: [ejbLite-3.1, jsp-2.2, javaee-7.0, cdi-1.0, transportSecurity-1.0, jaxws-2.2, localConnector-1.0, jaxrs-1.1, jpa-2.0, beanValidation-1.0]: CWWKF1405E: Les fonctions de singleton jsp-2.2 et jsp-2.3 sont incompatibles et ne peuvent pas être installées simultanément. CWWKF1405E: Les fonctions de singleton cdi-1.0 et cdi-1.2 sont incompatibles et ne peuvent pas être installées simultanément. CWWKF1405E: Les fonctions de singleton beanValidation-1.0 et beanValidation-1.1 sont incompatibles et ne peuvent pas être installées simultanément. CWWKF1405E: Les fonctions de singleton eeCompatible-6.0,eeCompatible-7.0, et eeCompatible-8.0 sont incompatibles et ne peuvent pas être installées simultanément. CWWKF1405E: Les fonctions de singleton ejb-3.1 et ejb-3.2 sont incompatibles et ne peuvent pas être installées simultanément. CWWKF1405E: Les fonctions de singleton interceptor-1.1 et interceptor-1.2 sont incompatibles et ne peuvent pas être installées simultanément. CWWKF1405E: Les fonctions de singleton jpa-2.0 et jpa-2.1 sont incompatibles et ne peuvent pas être installées simultanément. CWWKF1405E: Les fonctions de singleton internal-1.6 et internal-1.7 sont incompatibles et ne peuvent pas être installées simultanément. CWWKF1405E: Les fonctions de singleton el-2.2 et el-3.0 sont incompatibles et ne peuvent pas être installées simultanément. CWWKF1405E: Les fonctions de singleton jaxrs-1.1 et jaxrs-2.0 sont incompatibles et ne peuvent pas être installées simultanément. CWWKF1405E: Les fonctions de singleton transaction-1.1 et transaction-1.2 sont incompatibles et ne peuvent pas être installées simultanément. CWWKF1405E: Les fonctions de singleton ejbLite-3.1 et ejbLite-3.2 sont incompatibles et ne peuvent pas être installées simultanément.

at io.openliberty.tools.common.plugins.util.InstallFeatureUtil.installFeatures (InstallFeatureUtil.java:720)
at io.openliberty.tools.maven.server.InstallFeatureMojo.installFeatures (InstallFeatureMojo.java:112)
at io.openliberty.tools.maven.server.InstallFeatureMojo.doInstallFeatures (InstallFeatureMojo.java:75)
at io.openliberty.tools.maven.server.InstallFeatureMojo.execute (InstallFeatureMojo.java:66)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
at org.twdata.maven.mojoexecutor.MojoExecutor.executeMojo (MojoExecutor.java:120)
at io.openliberty.tools.maven.server.StartDebugMojoSupport.runLibertyMojo (StartDebugMojoSupport.java:362)
at io.openliberty.tools.maven.server.StartDebugMojoSupport.runLibertyMojoInstallFeature (StartDebugMojoSupport.java:347)
at io.openliberty.tools.maven.server.DevMojo.runLibertyMojoInstallFeature (DevMojo.java:1870)
at io.openliberty.tools.maven.server.DevMojo$DevMojoUtil.libertyInstallFeature (DevMojo.java:406)
at io.openliberty.tools.common.plugins.util.DevUtil.restartServer (DevUtil.java:1853)
at io.openliberty.tools.common.plugins.util.DevUtil$HotkeyReader.readInput (DevUtil.java:2610)
at io.openliberty.tools.common.plugins.util.DevUtil$HotkeyReader.run (DevUtil.java:2577)
at java.lang.Thread.run (Thread.java:750)

It seems the plugin looses track of the actual server configuration at this point.

This pb doesnt show when invoking dev mode within the -ws submodule directory.

Regards André

cherylking commented 1 year ago

@andre-doherty Can you include the console messages for the initial startup? I want to compare the features it installs on initial startup vs the restart. The console messages you included show the restart tries to install the same list of features as the server.xml. So I am not sure what you meant by:

It seems the plugin looses track of the actual server configuration at this point.

cherylking commented 1 year ago

I would like you to remove the features from the pom.xml. Just leave the acceptLicense in the pom.xml. The features should be in the server.xml and will get installed by the plugin. I believe the server is getting created by default with a server.xml that includes the javaee-7.0 feature (since you are using the wlp-javaee7 runtime) and it is trying to install that in addition to what you have in the pom.xml, and that is not compatible with all the javaee6 features.

Where is your server.xml located? Do you need to add the location to the plugin configuration in the pom.xml? If it is not in src/main/liberty/config it will not use it.

andre-doherty commented 1 year ago

@andre-doherty Can you include the console messages for the initial startup? I want to compare the features it installs on initial startup vs the restart. The console messages you included show the restart tries to install the same list of features as the server.xml. So I am not sure what you meant by:

It seems the plugin looses track of the actual server configuration at this point.

Hello @cherylking,

Please find the following : The feature installed matches the features listed in the server.xml (located in the default directory submodule-ws/src/main/liberty/config/server.xml.

[INFO] [AUDIT ] CWWKT0016I: Application Web disponible, (default_host) : http://localhost:9080/samplepim/ [INFO] [AUDIT ] CWWKZ0001I: Application samplepim3-ws démarrée en 2,871 secondes. [INFO] [AUDIT ] CWWKF0012I: Le serveur a installé les fonctions suivantes : [beanValidation-1.0, cdi-1.0, ejbLite-3.1, jaxb-2.2, jaxrs-1.1, jaxws-2.2, jdbc-4.2, jndi-1.0, jpa-2.0, json-1.0, jsp-2.2, localConnector-1.0, servlet-3.0, ssl-1.0, transportSecurity-1.0]. [INFO] [AUDIT ] CWWKF0011I: Le serveur defaultServer est prêt pour une planète plus intelligente. Il a démarré en 4,419 secondes. [INFO] CWWKM2015I: Le numéro correspondant est 1 à la ligne [19/09/23 19:26:48:451 CEST] 00000024 com.ibm.ws.kernel.feature.internal.FeatureManager A CWWKF0011I: Le serveur defaultServer est prêt pour une planète plus intelligente. Il a démarré en 4,419 secondes.. [INFO] **** [INFO] Liberty is running in dev mode. [INFO] Automatic generation of features: [ Off ] [INFO] h - see the help menu for available actions, type 'h' and press Enter. [INFO] q - stop the server and quit dev mode, press Ctrl-C or type 'q' and press Enter. [INFO]
[INFO]
Liberty server port information: [INFO] Liberty server HTTP port: [ 9080 ] [INFO] Liberty server HTTPS port: [ 9443 ] [INFO] * Liberty debug port: [ 7777 ] [INFO] **** Note: /Users/a983152/Workspace/git/pf-java/samples/sample.samplepim3-parent/samplepim3-service/src/main/java/fr/bnpp/pf/samplepim3/dao/CrudServiceImpl.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. [INFO] samplepim3-service source compilation was successful. Note: /Users/a983152/Workspace/git/pf-java/samples/sample.samplepim3-parent/samplepim3-service/src/test/java/fr/bnpp/pf/samplepim3/business/PersonServiceImplTest.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. [INFO] samplepim3-service tests compilation was successful. Note: /Users/a983152/Workspace/git/pf-java/samples/sample.samplepim3-parent/samplepim3-ws/src/main/java/fr/bnpp/pf/samplepim3/Samplepim3Init.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. [INFO] samplepim3-ws source compilation was successful.

Everything is fine until i try to restart the server... All configuration files are corrected picked on the first start.

andre-doherty commented 1 year ago

I would like you to remove the features from the pom.xml. Just leave the acceptLicense in the pom.xml. The features should be in the server.xml and will get installed by the plugin. I believe the server is getting created by default with a server.xml that includes the javaee-7.0 feature (since you are using the wlp-javaee7 runtime) and it is trying to install that in addition to what you have in the pom.xml, and that is not compatible with all the javaee6 features.

Where is your server.xml located? Do you need to add the location to the plugin configuration in the pom.xml? If it is not in src/main/liberty/config it will not use it.

The server.xml is correctly found (located in the default location) : datasources, libraries are configured.

So i have tried to remove the features list in the pom, doesn't change anything. Restart still fails.

Regards André

andre-doherty commented 1 year ago

Actually the plugin behaves just as if there was no server.xml, as if the module name specified in the command line with the pl switch was not kept.

andre-doherty commented 11 months ago

hello @cherylking,

Do you need some more elements ?

Regards, André

cherylking commented 11 months ago

@andre-doherty Can you provide a sample project to recreate?

Until then, I have a suggestion. Instead of using the wlp-javaee7 server when you are using Java EE 6 features, can you try using the wlp-kernel runtime artifactId instead?

andre-doherty commented 11 months ago

@andre-doherty Can you provide a sample project to recreate?

Hello @cherylking, Here you are : sample.zip

I have tried to minimize it as max as possible. To reproduce : from the parent pom run : mvn clean install mvn -am -pl module-ws io.openliberty.tools:liberty-maven-plugin:dev Try to restart the server using the 'r'

Note : i am using the following : mvn --version


Maven home: /opt/homebrew/Cellar/maven/3.9.3/libexec
Java version: 17.0.7, vendor: Homebrew, runtime: /opt/homebrew/Cellar/openjdk@17/17.0.7/libexec/openjdk.jdk/Contents/Home
Default locale: fr_FR, platform encoding: UTF-8
OS name: "mac os x", version: "14.0", arch: "aarch64", family: "mac"

André
cherylking commented 11 months ago

Thanks for the sample project @andre-doherty. I will try to work on this next week. Did you try the workaround?

andre-doherty commented 11 months ago

hello @cherylking, Yes, sorry i did not give you a feedback on the suggested workaround. It doesn't work as well, it fails also but with a different error.

[ERROR] Could not restart the server.
io.openliberty.tools.common.plugins.util.PluginExecutionException: org.apache.maven.plugin.MojoExecutionException: CWWKM2173E: Failed to install application from project project:lib:jar:0.0.1-SNAPSHOT. The project packaging type is not supported.
    at io.openliberty.tools.maven.server.DevMojo$DevMojoUtil.libertyDeploy (DevMojo.java:417)
    at io.openliberty.tools.common.plugins.util.DevUtil.restartServer (DevUtil.java:1855)
    at io.openliberty.tools.common.plugins.util.DevUtil$HotkeyReader.readInput (DevUtil.java:2610)
    at io.openliberty.tools.common.plugins.util.DevUtil$HotkeyReader.run (DevUtil.java:2577)
    at java.lang.Thread.run (Thread.java:833)
Caused by: org.apache.maven.plugin.MojoExecutionException: CWWKM2173E: Failed to install application from project project:lib:jar:0.0.1-SNAPSHOT. The project packaging type is not supported.
    at io.openliberty.tools.maven.applications.DeployMojo.installProject (DeployMojo.java:204)
    at io.openliberty.tools.maven.applications.DeployMojo.doDeploy (DeployMojo.java:103)
    at io.openliberty.tools.maven.applications.DeployMojo.execute (DeployMojo.java:61)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
    at org.twdata.maven.mojoexecutor.MojoExecutor.executeMojo (MojoExecutor.java:120)
    at io.openliberty.tools.maven.server.StartDebugMojoSupport.runLibertyMojo (StartDebugMojoSupport.java:362)
    at io.openliberty.tools.maven.server.StartDebugMojoSupport.runLibertyMojoDeploy (StartDebugMojoSupport.java:328)
    at io.openliberty.tools.maven.server.StartDebugMojoSupport.runLibertyMojoDeploy (StartDebugMojoSupport.java:311)
    at io.openliberty.tools.maven.server.DevMojo$DevMojoUtil.libertyDeploy (DevMojo.java:415)
    at io.openliberty.tools.common.plugins.util.DevUtil.restartServer (DevUtil.java:1855)
    at io.openliberty.tools.common.plugins.util.DevUtil$HotkeyReader.readInput (DevUtil.java:2610)
    at io.openliberty.tools.common.plugins.util.DevUtil$HotkeyReader.run (DevUtil.java:2577)
    at java.lang.Thread.run (Thread.java:833)

André

cherylking commented 11 months ago

You can test the fix with the 3.9-SNAPSHOT. We are targeting a release by the end of this week.

scottkurz commented 11 months ago

FWIW, just noting that I tried and failed to recreate this with Maven v3.8.8.... but I did succeed recreating on the noted v3.9.3. Thought that was interesting to observe the version-specific behavior for this Maven API.

andre-doherty commented 11 months ago

hello @cherylking, @scottkurz,

I have been able to test the version 3.9-SNAPSHOT this morning. The defect is gone.

Thanks a lot for your action ! Regards, André