无法使用来自 wildfly-swarm-examples/ribbon-consul 的 wildfly-swarm 实例定位领事服务
Unable to locate consul service with wildfly-swarm instance from wildfly-swarm-examples/ribbon-consul
按照 ribbon-consul example 中的说明,我使用
启动了 consul
consul agent -dev
然后在此示例的父文件夹中
mvn verify -Pconsul -Dswarm.consul.url=http://localhost:8500
据我所知,这是 consul 的默认位置,所以我也 运行 它没有,只是得到了相同的结果。
Task 最终启动了所有服务,但是未能向 consul 注册,输出:
2017-08-25 16:54:00,324 INFO [org.wildfly.swarm.runtime.deployer] (main) deploying time.war
2017-08-25 16:54:00,354 INFO [org.jboss.as.server.deployment] (MSC service thread 1-8) WFLYSRV0027: Starting deployment of "time.war" (runtime-name: "time.war")
2017-08-25 16:54:01,778 WARN [org.jboss.as.dependency.private] (MSC service thread 1-3) WFLYSRV0018: Deployment "deployment.time.war" is using a private module ("io.netty:main") which may be changed or removed in future versions without notice.
2017-08-25 16:54:01,923 INFO [org.wildfly.extension.undertow] (MSC service thread 1-2) WFLYUT0018: Host default-host starting
2017-08-25 16:54:02,036 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-6) MSC000001: Failed to start service swarm.topology.register.time.http: org.jboss.msc.service.StartException in service swarm.topology.register.time.http: com.orbitz.consul.ConsulException: Invalid service address
at org.wildfly.swarm.topology.deployment.RegistrationAdvertiser.start(RegistrationAdvertiser.java:79)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
Caused by: com.orbitz.consul.ConsulException: Invalid service address
at com.orbitz.consul.AgentClient.register(AgentClient.java:180)
at com.orbitz.consul.AgentClient.register(AgentClient.java:184)
at org.wildfly.swarm.topology.consul.runtime.Advertiser.advertise(Advertiser.java:65)
at org.wildfly.swarm.topology.consul.runtime.ConsulTopologyConnector.advertise(ConsulTopologyConnector.java:60)
at org.wildfly.swarm.topology.deployment.RegistrationAdvertiser.start(RegistrationAdvertiser.java:77)
... 5 more
2017-08-25 16:54:02,203 INFO [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 7) RESTEASY002225: Deploying javax.ws.rs.core.Application: class org.wildfly.swarm.generated.WildFlySwarmDefaultJAXRSApplication
2017-08-25 16:54:02,221 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 7) WFLYUT0021: Registered web context: /
2017-08-25 16:54:02,242 ERROR [org.jboss.as.controller.management-operation] (main) WFLYCTL0013: Operation ("add") failed - address: (("deployment" => "time.war")) - failure description: {
"WFLYCTL0080: Failed services" => {"swarm.topology.register.time.http" => "org.jboss.msc.service.StartException in service swarm.topology.register.time.http: com.orbitz.consul.ConsulException: Invalid service address
Caused by: com.orbitz.consul.ConsulException: Invalid service address"},
"WFLYCTL0412: Required services that are not installed:" => ["swarm.topology.register.time.http"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => undefined
}
2017-08-25 16:54:02,244 ERROR [org.jboss.as.server] (main) WFLYSRV0021: Deploy of deployment "time.war" was rolled back with the following failure message:
{
"WFLYCTL0080: Failed services" => {"swarm.topology.register.time.http" => "org.jboss.msc.service.StartException in service swarm.topology.register.time.http: com.orbitz.consul.ConsulException: Invalid service address
Caused by: com.orbitz.consul.ConsulException: Invalid service address"},
"WFLYCTL0412: Required services that are not installed:" => ["swarm.topology.register.time.http"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => undefined
}
2017-08-25 16:54:02,250 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 7) WFLYUT0022: Unregistered web context: /
2017-08-25 16:54:02,254 INFO [org.wildfly.extension.undertow] (MSC service thread 1-2) WFLYUT0019: Host default-host stopping
2017-08-25 16:54:02,272 INFO [org.jboss.as.server.deployment] (MSC service thread 1-7) WFLYSRV0028: Stopped deployment time.war (runtime-name: time.war) in 28ms
2017-08-25 16:54:02,273 INFO [org.jboss.as.controller] (main) WFLYCTL0183: Service status report
WFLYCTL0186: Services which failed to start: service swarm.topology.register.time.http
2017-08-25 16:54:02,275 ERROR [stderr] (main) Exception in thread "main" java.lang.reflect.InvocationTargetException
2017-08-25 16:54:02,275 ERROR [stderr] (main) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2017-08-25 16:54:02,275 ERROR [stderr] (main) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
2017-08-25 16:54:02,275 ERROR [stderr] (main) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2017-08-25 16:54:02,275 ERROR [stderr] (main) at java.lang.reflect.Method.invoke(Method.java:498)
2017-08-25 16:54:02,275 ERROR [stderr] (main) at org.wildfly.swarm.bootstrap.MainInvoker.invoke(MainInvoker.java:39)
2017-08-25 16:54:02,276 ERROR [stderr] (main) at org.wildfly.swarm.bootstrap.MainInvoker.main(MainInvoker.java:92)
2017-08-25 16:54:02,276 ERROR [stderr] (main) Caused by: org.wildfly.swarm.container.DeploymentException: org.wildfly.swarm.container.DeploymentException: WFSWARM0004: Deployment failed: {"WFLYCTL0080: Failed services" => {"swarm.topology.register.time.http" => "org.jboss.msc.service.StartException in service swarm.topology.register.time.http: com.orbitz.consul.ConsulException: Invalid service address
2017-08-25 16:54:02,276 ERROR [stderr] (main) Caused by: com.orbitz.consul.ConsulException: Invalid service address"},"WFLYCTL0412: Required services that are not installed:" => ["swarm.topology.register.time.http"],"WFLYCTL0180: Services with missing/unavailable dependencies" => undefined}
2017-08-25 16:54:02,276 ERROR [stderr] (main) at org.wildfly.swarm.container.runtime.RuntimeDeployer.deploy(RuntimeDeployer.java:301)
2017-08-25 16:54:02,276 ERROR [stderr] (main) at org.wildfly.swarm.container.runtime.RuntimeDeployer.deploy(RuntimeDeployer.java:174)
2017-08-25 16:54:02,276 ERROR [stderr] (main) at org.wildfly.swarm.container.runtime.RuntimeDeployer$Proxy$_$$_WeldClientProxy.deploy(Unknown Source)
2017-08-25 16:54:02,277 ERROR [stderr] (main) at org.wildfly.swarm.Swarm.deploy(Swarm.java:467)
2017-08-25 16:54:02,277 ERROR [stderr] (main) at org.wildfly.swarm.examples.netflix.ribbon.time.Main.main(Main.java:19)
2017-08-25 16:54:02,277 ERROR [stderr] (main) ... 6 more
2017-08-25 16:54:02,278 ERROR [stderr] (main) Caused by: org.wildfly.swarm.container.DeploymentException: WFSWARM0004: Deployment failed: {"WFLYCTL0080: Failed services" => {"swarm.topology.register.time.http" => "org.jboss.msc.service.StartException in service swarm.topology.register.time.http: com.orbitz.consul.ConsulException: Invalid service address
2017-08-25 16:54:02,278 ERROR [stderr] (main) Caused by: com.orbitz.consul.ConsulException: Invalid service address"},"WFLYCTL0412: Required services that are not installed:" => ["swarm.topology.register.time.http"],"WFLYCTL0180: Services with missing/unavailable dependencies" => undefined}
2017-08-25 16:54:02,278 ERROR [stderr] (main) at org.wildfly.swarm.container.runtime.RuntimeDeployer.deploy(RuntimeDeployer.java:296)
2017-08-25 16:54:02,278 ERROR [stderr] (main) ... 10 more
每次事件服务启动时都会重复此操作。前端在 http://:8300
.
报告领事服务
从带偏移的想法开始主要方法将执行良好(前端 returns 403:forbidden,但这是另一个问题)
我是否遗漏了什么,因为这似乎是一个很容易被窃听的简单示例?
受影响的示例版本是 2017.9.0-SNAPSHOT
和 2017.8.1
。
Consul 客户端异常 "Invalid service address" 表示正在使用 IP“0.0.0.0”注册服务。参见 consul source code
默认情况下,Swarm 的 "swarm.bind.address" 属性 默认值为“0.0.0.0”,这意味着接受“所有接口”到 Swarm 的连接。
看来这个IP是用来注册consul服务的。
尝试在 test/pom.xml 中为每个进程指定 swarm.bind.address 系统 属性,例如
<process>
<artifactId>example-ribbon-consul-time</artifactId>
<properties>
<swarm.http.port>8081</swarm.http.port>
<swarm.bind.address>127.0.0.1</swarm.bind.address>
</properties>
</process>
按照 ribbon-consul example 中的说明,我使用
启动了 consulconsul agent -dev
然后在此示例的父文件夹中
mvn verify -Pconsul -Dswarm.consul.url=http://localhost:8500
据我所知,这是 consul 的默认位置,所以我也 运行 它没有,只是得到了相同的结果。 Task 最终启动了所有服务,但是未能向 consul 注册,输出:
2017-08-25 16:54:00,324 INFO [org.wildfly.swarm.runtime.deployer] (main) deploying time.war
2017-08-25 16:54:00,354 INFO [org.jboss.as.server.deployment] (MSC service thread 1-8) WFLYSRV0027: Starting deployment of "time.war" (runtime-name: "time.war")
2017-08-25 16:54:01,778 WARN [org.jboss.as.dependency.private] (MSC service thread 1-3) WFLYSRV0018: Deployment "deployment.time.war" is using a private module ("io.netty:main") which may be changed or removed in future versions without notice.
2017-08-25 16:54:01,923 INFO [org.wildfly.extension.undertow] (MSC service thread 1-2) WFLYUT0018: Host default-host starting
2017-08-25 16:54:02,036 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-6) MSC000001: Failed to start service swarm.topology.register.time.http: org.jboss.msc.service.StartException in service swarm.topology.register.time.http: com.orbitz.consul.ConsulException: Invalid service address
at org.wildfly.swarm.topology.deployment.RegistrationAdvertiser.start(RegistrationAdvertiser.java:79)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
Caused by: com.orbitz.consul.ConsulException: Invalid service address
at com.orbitz.consul.AgentClient.register(AgentClient.java:180)
at com.orbitz.consul.AgentClient.register(AgentClient.java:184)
at org.wildfly.swarm.topology.consul.runtime.Advertiser.advertise(Advertiser.java:65)
at org.wildfly.swarm.topology.consul.runtime.ConsulTopologyConnector.advertise(ConsulTopologyConnector.java:60)
at org.wildfly.swarm.topology.deployment.RegistrationAdvertiser.start(RegistrationAdvertiser.java:77)
... 5 more
2017-08-25 16:54:02,203 INFO [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 7) RESTEASY002225: Deploying javax.ws.rs.core.Application: class org.wildfly.swarm.generated.WildFlySwarmDefaultJAXRSApplication
2017-08-25 16:54:02,221 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 7) WFLYUT0021: Registered web context: /
2017-08-25 16:54:02,242 ERROR [org.jboss.as.controller.management-operation] (main) WFLYCTL0013: Operation ("add") failed - address: (("deployment" => "time.war")) - failure description: {
"WFLYCTL0080: Failed services" => {"swarm.topology.register.time.http" => "org.jboss.msc.service.StartException in service swarm.topology.register.time.http: com.orbitz.consul.ConsulException: Invalid service address
Caused by: com.orbitz.consul.ConsulException: Invalid service address"},
"WFLYCTL0412: Required services that are not installed:" => ["swarm.topology.register.time.http"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => undefined
}
2017-08-25 16:54:02,244 ERROR [org.jboss.as.server] (main) WFLYSRV0021: Deploy of deployment "time.war" was rolled back with the following failure message:
{
"WFLYCTL0080: Failed services" => {"swarm.topology.register.time.http" => "org.jboss.msc.service.StartException in service swarm.topology.register.time.http: com.orbitz.consul.ConsulException: Invalid service address
Caused by: com.orbitz.consul.ConsulException: Invalid service address"},
"WFLYCTL0412: Required services that are not installed:" => ["swarm.topology.register.time.http"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => undefined
}
2017-08-25 16:54:02,250 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 7) WFLYUT0022: Unregistered web context: /
2017-08-25 16:54:02,254 INFO [org.wildfly.extension.undertow] (MSC service thread 1-2) WFLYUT0019: Host default-host stopping
2017-08-25 16:54:02,272 INFO [org.jboss.as.server.deployment] (MSC service thread 1-7) WFLYSRV0028: Stopped deployment time.war (runtime-name: time.war) in 28ms
2017-08-25 16:54:02,273 INFO [org.jboss.as.controller] (main) WFLYCTL0183: Service status report
WFLYCTL0186: Services which failed to start: service swarm.topology.register.time.http
2017-08-25 16:54:02,275 ERROR [stderr] (main) Exception in thread "main" java.lang.reflect.InvocationTargetException
2017-08-25 16:54:02,275 ERROR [stderr] (main) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2017-08-25 16:54:02,275 ERROR [stderr] (main) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
2017-08-25 16:54:02,275 ERROR [stderr] (main) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2017-08-25 16:54:02,275 ERROR [stderr] (main) at java.lang.reflect.Method.invoke(Method.java:498)
2017-08-25 16:54:02,275 ERROR [stderr] (main) at org.wildfly.swarm.bootstrap.MainInvoker.invoke(MainInvoker.java:39)
2017-08-25 16:54:02,276 ERROR [stderr] (main) at org.wildfly.swarm.bootstrap.MainInvoker.main(MainInvoker.java:92)
2017-08-25 16:54:02,276 ERROR [stderr] (main) Caused by: org.wildfly.swarm.container.DeploymentException: org.wildfly.swarm.container.DeploymentException: WFSWARM0004: Deployment failed: {"WFLYCTL0080: Failed services" => {"swarm.topology.register.time.http" => "org.jboss.msc.service.StartException in service swarm.topology.register.time.http: com.orbitz.consul.ConsulException: Invalid service address
2017-08-25 16:54:02,276 ERROR [stderr] (main) Caused by: com.orbitz.consul.ConsulException: Invalid service address"},"WFLYCTL0412: Required services that are not installed:" => ["swarm.topology.register.time.http"],"WFLYCTL0180: Services with missing/unavailable dependencies" => undefined}
2017-08-25 16:54:02,276 ERROR [stderr] (main) at org.wildfly.swarm.container.runtime.RuntimeDeployer.deploy(RuntimeDeployer.java:301)
2017-08-25 16:54:02,276 ERROR [stderr] (main) at org.wildfly.swarm.container.runtime.RuntimeDeployer.deploy(RuntimeDeployer.java:174)
2017-08-25 16:54:02,276 ERROR [stderr] (main) at org.wildfly.swarm.container.runtime.RuntimeDeployer$Proxy$_$$_WeldClientProxy.deploy(Unknown Source)
2017-08-25 16:54:02,277 ERROR [stderr] (main) at org.wildfly.swarm.Swarm.deploy(Swarm.java:467)
2017-08-25 16:54:02,277 ERROR [stderr] (main) at org.wildfly.swarm.examples.netflix.ribbon.time.Main.main(Main.java:19)
2017-08-25 16:54:02,277 ERROR [stderr] (main) ... 6 more
2017-08-25 16:54:02,278 ERROR [stderr] (main) Caused by: org.wildfly.swarm.container.DeploymentException: WFSWARM0004: Deployment failed: {"WFLYCTL0080: Failed services" => {"swarm.topology.register.time.http" => "org.jboss.msc.service.StartException in service swarm.topology.register.time.http: com.orbitz.consul.ConsulException: Invalid service address
2017-08-25 16:54:02,278 ERROR [stderr] (main) Caused by: com.orbitz.consul.ConsulException: Invalid service address"},"WFLYCTL0412: Required services that are not installed:" => ["swarm.topology.register.time.http"],"WFLYCTL0180: Services with missing/unavailable dependencies" => undefined}
2017-08-25 16:54:02,278 ERROR [stderr] (main) at org.wildfly.swarm.container.runtime.RuntimeDeployer.deploy(RuntimeDeployer.java:296)
2017-08-25 16:54:02,278 ERROR [stderr] (main) ... 10 more
每次事件服务启动时都会重复此操作。前端在 http://:8300
.
从带偏移的想法开始主要方法将执行良好(前端 returns 403:forbidden,但这是另一个问题)
我是否遗漏了什么,因为这似乎是一个很容易被窃听的简单示例?
受影响的示例版本是 2017.9.0-SNAPSHOT
和 2017.8.1
。
Consul 客户端异常 "Invalid service address" 表示正在使用 IP“0.0.0.0”注册服务。参见 consul source code
默认情况下,Swarm 的 "swarm.bind.address" 属性 默认值为“0.0.0.0”,这意味着接受“所有接口”到 Swarm 的连接。 看来这个IP是用来注册consul服务的。
尝试在 test/pom.xml 中为每个进程指定 swarm.bind.address 系统 属性,例如
<process>
<artifactId>example-ribbon-consul-time</artifactId>
<properties>
<swarm.http.port>8081</swarm.http.port>
<swarm.bind.address>127.0.0.1</swarm.bind.address>
</properties>
</process>