OpenLiberty / OpenLiberty/ci.common
`libertyDevc` / `devc` reports "Unable to retrieve locally mapped port" when Liberty HTTP port is set to a non-default value
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 4
- Forks
- 32
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 5
Description
Repositories affected
ci.common(root cause inDevUtil.java)ci.gradle(surface vialibertyDevc)ci.maven(surface vialiberty:devc)
Summary
When a user configures a non-default Liberty HTTP/HTTPS port — either through Liberty server
variables (e.g. liberty.server.var.'default.http.port' = '9090' in Gradle, or
<liberty.var.default.http.port>9090</liberty.var.default.http.port> in Maven) or through a
hardcoded literal port in server.xml (e.g.
<httpEndpoint httpPort="9090" httpsPort="9453" ... />), libertyDevc/devc always maps the
hardcoded default ports 9080 and 9443 in the container run command
(-p 9080:9080 -p 9443:9443). The Liberty server inside the container starts on the
user-configured port (9090), which is not published. After startup, the plugin queries the
container for the mapped port of 9090 and receives an error:
Unable to retrieve locally mapped port. Container result:
"Error: failed to find published port "9090"".
Ensure the container ports are mapped correctly.
The plugin continues but can only report the internal container port (9090), not a usable
localhost address. The welcome page URL printed in the startup banner is wrong or absent.
Steps to reproduce
Via server variables (Gradle)
- Create a Maven or Gradle project with a Liberty module.
- Override the Liberty HTTP port via server variables in the build file:
liberty { server { var.'default.http.port' = '9090' var.'default.https.port' = '9453' } } - Run
libertyDevc(Gradle) orliberty:devc(Maven).
Via literal port in server.xml
- Configure a non-default port directly in
server.xml:<httpEndpoint httpPort="9090" httpsPort="9453" ... /> - Run
libertyDevc/liberty:devc.
Both cases produce the same failure
- Observe the
CWWKT0016Ilog line reporting port 9090. - The startup banner shows:
NoUnable to retrieve locally mapped port. Container result: "Error: failed to find published port "9090"" Internal container HTTP port: [ 9090 ]localhostwelcome URL is shown for the correctly configured port.
Root cause
DevUtil.getContainerCommand() — only defaults are ever published
(ci.common DevUtil.java)
getContainerCommand() unconditionally maps only the two Liberty default ports at build time:
if (!skipDefaultPorts) {
int httpPortToUse = findAndHoldPort(LIBERTY_DEFAULT_HTTP_PORT, false, heldSockets); // 9080
int httpsPortToUse = findAndHoldPort(LIBERTY_DEFAULT_HTTPS_PORT, false, heldSockets); // 9443
commandElements.add("-p");
commandElements.add(httpPortToUse + ":" + LIBERTY_DEFAULT_HTTP_PORT);
commandElements.add("-p");
commandElements.add(httpsPortToUse + ":" + LIBERTY_DEFAULT_HTTPS_PORT);
}
This is the only port-mapping code in the container run command builder. There is no code
path that reads the effective HTTP/HTTPS port from any configuration source before building
the command. Neither server.xml nor liberty-plugin-variable-config.xml is parsed for
httpEndpoint attributes or variable values at this point.
The container run command therefore never publishes the port the Liberty server will actually
bind to if that port differs from 9080/9443.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in ci.common/src/main/java/io/openliberty/tools/common/plugins/util/DevUtil.java at getContainerCommand() around line 1696, then trace how libertyDevc and liberty:devc provide configuration. Reproduce with a non-default port from server variables and server.xml; done means the configured HTTP/HTTPS ports are published and the startup banner reports a usable localhost URL.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100