Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to start two apps with the same name #583

Closed
Emily-Jiang opened this issue Sep 14, 2019 · 11 comments
Closed

Unable to start two apps with the same name #583

Emily-Jiang opened this issue Sep 14, 2019 · 11 comments
Assignees
Labels
devMode high priority vNext Targeted for next release

Comments

@Emily-Jiang
Copy link
Member

Emily-Jiang commented Sep 14, 2019

I found another issue with liberty:dev. Since my server.xml has webApplication, which will put .war under apps, while liberty:dev uses loose mode. I got the following error:
[INFO] [ERROR ] CWWKZ0013E: It is not possible to start two applications called demo.

@Emily-Jiang
Copy link
Member Author

Emily-Jiang commented Sep 14, 2019

pom.xml

@Emily-Jiang
Copy link
Member Author

server.xml

@yeekangc
Copy link
Member

yeekangc commented Sep 15, 2019

Emily, are you customizing the plugin configuration for particular reasons?

With 3.0 or above, you should only need to specify the below:

<plugin>
                <groupId>io.openliberty.tools</groupId>
                <artifactId>liberty-maven-plugin</artifactId>
                <version>3.0.1</version>
</plugin>

@cherylking
Copy link
Member

When I was recreating the issue, I found the following in the console:

[debug] Variable project.name cannot be resolved.
[info] The variables referenced by location ${project.name}.war cannot be resolved.

That is why the app is getting defined in configDropins folder, resulting in two apps configured for the server. Need to determine why that variable cannot be resolved. I see it in bootstrap.properties. Will debug further.

@scottkurz
Copy link
Member

I debugged to the point that I see a potential issue.

The DevMojo calls the DeployMojo like this:

    // update target server configuration
    copyConfigFiles();
    exportParametersToXml();

but copyConfigFiles() doesn't see the "inlined" bootstrap.properties.

So the "is the app configured" calculation can't resolve <webApplication location="${project.name}.war" with "${project.name}" intended to come from bootstrap.properties, and so we generate the configDropin with the "second" config of this app.

A bit later, when it's time to actually start the server, though, the bootstrap.properties are set on the mojo config.

I wonder if it's because the io.openliberty.tools.maven.server.DevMojo.getPluginConfigurationElements(String, String, List<String>) logic is selectively propagating or not propagating config..and not doing the right thing for bootstrap.properties?

@scottkurz
Copy link
Member

scottkurz commented Sep 15, 2019

I tried a fix in this branch which seems to fix part of the problem:
https://github.com/scottkurz/ci.maven/pull/new/propagate-bootstrap-props-in-dev-mode
but didn't actually submit the PR.

Not sure if there's already a util for building mojo executor Element(s) from Maven xpp3dom (I coded part of one).

I observed that, probably because of plugin prefix resolution.. you have to install locally the parent module... you can't just build/install the liberty-maven-plugin module like I'd sometimes try to do as a shortcut.

@yeekangc
Copy link
Member

@ericglau

@cherylking cherylking added devMode high priority vNext Targeted for next release labels Sep 16, 2019
@cherylking
Copy link
Member

Same as issue #581 ?

@ericglau
Copy link
Contributor

I can reproduce this with this project https://github.com/Emily-Jiang/reactive-service-b

Looks related to parsing a variable from the server.xml

[INFO] CWWKM2144I: Update server configuration file server.xml from /Users/eric/git/reactive-service-b/src/main/liberty/config/server.xml.
[debug] Variable project.name cannot be resolved.
[info] The variables referenced by location ${project.name}.war cannot be resolved.
[debug] Variable project.name cannot be resolved.
[INFO] CWWKM2185I: The liberty-maven-plugin configuration parameter "appsDirectory" value defaults to "apps".
[INFO] CWWKM2160I: Installing application demo.war.xml.
[WARNING] CWWKM2179W: The application is not defined in the server configuration but the POM configuration indicates it should be installed in the apps folder. Application configuration is being added to the target server configuration dropins folder by the plug-in.
[INFO] Successfully created liberty:dev server.env file
[INFO] Copying 1 file to /Users/eric/git/reactive-service-b/target/liberty/wlp/usr/servers/demo
[INFO] Copying 1 file to /Users/eric/git/reactive-service-b/target/liberty/wlp/usr/servers/demo
[INFO] CWWKM2144I: Update server configuration file server.xml from /Users/eric/git/reactive-service-b/src/main/liberty/config/server.xml.
[INFO] CWWKM2144I: Update server configuration file bootstrap.properties from inlined configuration.
[INFO] CWWKM2001I: server.config.dir is /Users/eric/git/reactive-service-b/target/liberty/wlp/usr/servers/demo.
[INFO] CWWKM2010I: Searching for CWWKZ0001I.* in /Users/eric/git/reactive-service-b/target/liberty/wlp/usr/servers/demo/logs/messages.log. This search will timeout after 30 seconds.
[INFO] CWWKM2001I: server.output.dir is /Users/eric/git/reactive-service-b/target/liberty/wlp/usr/servers/demo.
[INFO] CWWKM2013I: The file /Users/eric/git/reactive-service-b/target/liberty/wlp/usr/servers/demo/logs/messages.log being validated does not exist.
[INFO] CWWKM2001I: Invoke command is [/Users/eric/git/reactive-service-b/target/liberty/wlp/bin/server, debug, demo].
[INFO] 
[INFO] Listening for transport dt_socket at address: 7777
[INFO] CWWKM2013I: The file /Users/eric/git/reactive-service-b/target/liberty/wlp/usr/servers/demo/logs/messages.log being validated does not exist.
[INFO] Launching demo (Open Liberty 19.0.0.9/wlp-1.0.32.cl190920190905-0148) on Eclipse OpenJ9 VM, version 11.0.4+11 (en_CA)
[INFO] [AUDIT   ] CWWKE0001I: The server demo has been launched.
[INFO] [AUDIT   ] CWWKG0093A: Processing configuration drop-ins resource: /Users/eric/git/reactive-service-b/target/liberty/wlp/usr/servers/demo/configDropins/defaults/install_apps_configuration_1491924271.xml
[INFO] [AUDIT   ] CWWKZ0058I: Monitoring dropins for applications.
[INFO] [ERROR   ] CWWKZ0013E: It is not possible to start two applications called demo.

@edburns
Copy link

edburns commented May 20, 2021

Hello @scottkurz ,

Thanks for your excellent work on my stackoverflow question. It reminds me of the golden days when BalusC would be so all over JSF questions on StackOveflow I wondered if he was an AI (he's not).

I tried to apply your advice in this fork/branch to my simple use case, which seems exactly the same as @Emily-Jiang 's here. In my case I'm using ${project.artifactId} and Emily is using ${project.name}. In both cases I see the dreaded CWWKZ0013E: It is not possible to start two applications called guide-getting-started. error. What's worse, I observe some non-deterministic behavior: sometimes the app starts on "/" and other times on "/getting-started-guide". Is this a regression? Please see the pom in the github.

@scottkurz
Copy link
Member

scottkurz commented May 21, 2021

Thanks for your excellent work on my stackoverflow question. It reminds me of the golden days when BalusC would be so all over JSF questions on StackOveflow I wondered if he was an AI (he's not).

@edburns I don't deserve such praise, but thank you for your appreciation :)

Yes, the liberty-maven-plugin is failing to parse the server.xml correctly in order to determine the deployed app location. It's doing this in order to determine if it needs to generate config for the app deployment. But it's not handling variables correctly on the webApplication location itself and on the include location, supplying the "filtered" variable that I suggested you create on the StackOverflow post. I opened #1145 to follow-up on that.

I'm going to gloss over the "non-deterministic" aspect just a bit without a full explanation. The reason is that I know from experience there is a cache involved that can lead to experiences like you mentioned where it doesn't work the same each time. Acknowledging, not explaining, I know.

Also, it looks like you may have only really be using your own config to select a context root of "/".
<webApplication location="${project.artifactId}.war" contextRoot="/" />

I also opened issue: #1146 to see if we might find an easier way to use our plugin-generated config with a different ctx root like "/", in which case you might not need to worry about resolving variables in your own config.

Thanks for working through this with us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devMode high priority vNext Targeted for next release
Projects
None yet
Development

No branches or pull requests

6 participants