This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-4.18.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-4.18.x by this push:
     new a4233ab97d90 Fix camel hawtio to explicitly set host address for Jetty 
binding (#22869)
a4233ab97d90 is described below

commit a4233ab97d90556a046afdfd29fb5eb01a2ee123
Author: Salvatore Mongiardo <[email protected]>
AuthorDate: Thu Apr 30 17:18:31 2026 +0200

    Fix camel hawtio to explicitly set host address for Jetty binding (#22869)
    
    Backport of #22835 to camel-4.18.x.
    
    The `camel hawtio` command was not calling `setHost()` on hawtio-embedded,
    leaving the host unconfigured. On s390x/ppc64le systems,
    `InetAddress.getByName("localhost")` may resolve to `::1` (IPv6), causing
    Jetty to bind to an unreachable address, resulting in a 
ClosedChannelException.
    
    Fix: explicitly call `setHost("127.0.0.1")` (IPv4 loopback) to avoid
    ambiguous localhost resolution, and expose a `--host` CLI option for 
flexibility.
---
 .../modules/ROOT/pages/jbang-commands/camel-jbang-hawtio.adoc     | 1 +
 .../resources/META-INF/camel-jbang-commands-metadata.json         | 2 +-
 .../org/apache/camel/dsl/jbang/core/commands/process/Hawtio.java  | 8 +++++++-
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git 
a/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-hawtio.adoc 
b/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-hawtio.adoc
index 3ed8568de5ee..6035efa2ae51 100644
--- a/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-hawtio.adoc
+++ b/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-hawtio.adoc
@@ -19,6 +19,7 @@ camel hawtio [options]
 [cols="2,5,1,2",options="header"]
 |===
 | Option | Description | Default | Type
+| `--host` | Hostname to bind the Hawtio web console to | 127.0.0.1 | String
 | `--openUrl` | To automatic open Hawtio web console in the web browser | true 
| boolean
 | `--port` | Port number to use for Hawtio web console (port 8888 by default) 
| 8888 | int
 | `--version` | Version of the Hawtio web console | 
HawtioVersion.HAWTIO_VERSION | String
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/generated/resources/META-INF/camel-jbang-commands-metadata.json
 
b/dsl/camel-jbang/camel-jbang-core/src/generated/resources/META-INF/camel-jbang-commands-metadata.json
index 818d16ff85be..85c365adf03a 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/generated/resources/META-INF/camel-jbang-commands-metadata.json
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/generated/resources/META-INF/camel-jbang-commands-metadata.json
@@ -14,7 +14,7 @@
     { "name": "export", "fullName": "export", "description": "Export to other 
runtimes (Camel Main, Spring Boot, or Quarkus)", "sourceClass": 
"org.apache.camel.dsl.jbang.core.commands.Export", "options": [ { "names": 
"--build-property", "description": "Maven\/Gradle build properties, ex. 
--build-property=prop1=foo", "javaType": "java.util.List", "type": "array" }, { 
"names": "--build-tool", "description": "DEPRECATED: Build tool to use (maven 
or gradle) (gradle is deprecated)", "defaultV [...]
     { "name": "get", "fullName": "get", "description": "Get status of Camel 
integrations", "sourceClass": 
"org.apache.camel.dsl.jbang.core.commands.process.CamelStatus", "options": [ { 
"names": "--watch", "description": "Execute periodically and showing output 
fullscreen", "javaType": "boolean", "type": "boolean" }, { "names": 
"-h,--help", "description": "Display the help and sub-commands", "javaType": 
"boolean", "type": "boolean" } ], "subcommands": [ { "name": "bean", 
"fullName": "get  [...]
     { "name": "harden", "fullName": "harden", "description": "Suggest security 
hardening for Camel routes using AI\/LLM", "sourceClass": 
"org.apache.camel.dsl.jbang.core.commands.Harden", "options": [ { "names": 
"--api-key", "description": "API key for authentication. Also reads 
OPENAI_API_KEY or LLM_API_KEY env vars", "javaType": "java.lang.String", 
"type": "string" }, { "names": "--api-type", "description": "API type: 'ollama' 
or 'openai' (OpenAI-compatible)", "defaultValue": "ollama", [...]
-    { "name": "hawtio", "fullName": "hawtio", "description": "Launch Hawtio 
web console", "sourceClass": 
"org.apache.camel.dsl.jbang.core.commands.process.Hawtio", "options": [ { 
"names": "--openUrl", "description": "To automatic open Hawtio web console in 
the web browser", "defaultValue": "true", "javaType": "boolean", "type": 
"boolean" }, { "names": "--port", "description": "Port number to use for Hawtio 
web console (port 8888 by default)", "defaultValue": "8888", "javaType": "int", 
"t [...]
+    { "name": "hawtio", "fullName": "hawtio", "description": "Launch Hawtio 
web console", "sourceClass": 
"org.apache.camel.dsl.jbang.core.commands.process.Hawtio", "options": [ { 
"names": "--host", "description": "Hostname to bind the Hawtio web console to", 
"defaultValue": "127.0.0.1", "javaType": "java.lang.String", "type": "string" 
}, { "names": "--openUrl", "description": "To automatic open Hawtio web console 
in the web browser", "defaultValue": "true", "javaType": "boolean", "type": 
[...]
     { "name": "infra", "fullName": "infra", "description": "List and Run 
external services for testing and prototyping", "sourceClass": 
"org.apache.camel.dsl.jbang.core.commands.infra.InfraCommand", "options": [ { 
"names": "--json", "description": "Output in JSON Format", "javaType": 
"boolean", "type": "boolean" }, { "names": "-h,--help", "description": "Display 
the help and sub-commands", "javaType": "boolean", "type": "boolean" } ], 
"subcommands": [ { "name": "get", "fullName": "infra  [...]
     { "name": "init", "fullName": "init", "description": "Creates a new Camel 
integration", "sourceClass": "org.apache.camel.dsl.jbang.core.commands.Init", 
"options": [ { "names": "--clean-dir,--clean-directory", "description": 
"Whether to clean directory first (deletes all files in directory)", 
"javaType": "boolean", "type": "boolean" }, { "names": "--dir,--directory", 
"description": "Directory relative path where the new Camel integration will be 
saved", "defaultValue": ".", "javaType" [...]
     { "name": "jolokia", "fullName": "jolokia", "description": "Attach Jolokia 
JVM Agent to a running Camel integration", "sourceClass": 
"org.apache.camel.dsl.jbang.core.commands.process.Jolokia", "options": [ { 
"names": "--port", "description": "To use a specific port number when attaching 
Jolokia JVM Agent (default a free port is found in range 8778-9999)", 
"javaType": "int", "type": "integer" }, { "names": "--stop", "description": 
"Stops the Jolokia JVM Agent in the running Camel inte [...]
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/Hawtio.java
 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/Hawtio.java
index 0502e5a2ef7b..14325b4e71e9 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/Hawtio.java
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/Hawtio.java
@@ -46,6 +46,10 @@ public class Hawtio extends CamelCommand {
                         description = "Port number to use for Hawtio web 
console (port 8888 by default)", defaultValue = "8888")
     int port = 8888;
 
+    @CommandLine.Option(names = { "--host" },
+                        description = "Hostname to bind the Hawtio web console 
to", defaultValue = "127.0.0.1")
+    String host = "127.0.0.1";
+
     @CommandLine.Option(names = { "--openUrl" },
                         description = "To automatic open Hawtio web console in 
the web browser", defaultValue = "true")
     boolean openUrl = true;
@@ -116,6 +120,8 @@ public class Hawtio extends CamelCommand {
                 Object hawt = clazz.getDeclaredConstructor().newInstance();
                 Method m = clazz.getMethod("setWar", String.class);
                 ObjectHelper.invokeMethod(m, hawt, war);
+                m = clazz.getMethod("setHost", String.class);
+                ObjectHelper.invokeMethod(m, hawt, host);
                 m = clazz.getMethod("setPort", Integer.class);
                 ObjectHelper.invokeMethod(m, hawt, port);
                 m = clazz.getMethod("run");
@@ -123,7 +129,7 @@ public class Hawtio extends CamelCommand {
 
                 if (openUrl) {
                     // open web browser
-                    String url = "http://localhost:"; + port + "/hawtio";
+                    String url = "http://"; + host + ":" + port + "/hawtio";
                     System.setProperty("hawtio.url", url);
                     if (openUrl && Desktop.isDesktopSupported()) {
                         try {

Reply via email to