Ich entwickle die Wildfly-Swarm-App und möchte Consul als meine Service-Entdeckung verwenden. Also habe ich Topologie-Consul-Fraktion hinzugefügt, meinen Consul-Pfad in project-defaults.yml gesetzt und @Advertise("service-name")
zu meinem Endpoint hinzugefügt.Wildfly-Swarm Consul Service Discovery - Ungültige Serviceadresse
Und wenn ich meine Anwendung starten funktioniert mit
java –jar my-swarm-app.jar
alles gut.
Mein Projekt-defaults.yml:
service:
catalog:
service-name: "service-name"
swarm:
port:
offset: 501
consul:
url: "http://172.30.3.80:8500"
Aber wenn ich mein Fett Glas mit diesem Dockerfile innen Docker Bild packen:
FROM openjdk:8-jre-alpine
ADD my-swarm-app.jar /opt/my-swarm-app.jar
EXPOSE 8581
ENTRYPOINT ["java", "-jar", "-Djava.net.preferIPv4Stack=true", "/opt/my-swarm-app.jar"]
es Körperbau:
docker build -f Dockerfile -t my-swarm-app .
Und Führen Sie es so:
docker run -p 8581:8581 my-swarm-app
ich folgende Ausnahme erhalten:
2017-09-26 15:17:54,240 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC000001: Failed to start service swarm.topology.register.consent-service.http: org.jboss.msc.service.StartException in service swarm.topology.register.consent-service.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:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
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
Mache ich etwas falsch?
EDIT: Ich habe tryed Self-Service-Entdeckung Umsetzung mit Consul-api.
<dependency>
<groupId>com.ecwid.consul</groupId>
<artifactId>consul-api</artifactId>
<version>1.2.4</version>
</dependency>
Wie so:
@ApplicationScoped
public class Config {
private ConsulClient client;
@Inject
@ConfigurationValue("swarm.http.port")
private Integer port;
public void init(@Observes @Initialized(ApplicationScoped.class) ServletContext context) {
client = new ConsulClient("http://172.30.3.80:8500");
// register new service with associated health check
NewService newService = new NewService();
newService.setId("myapp_02");
newService.setTags(Collections.singletonList("EU-East"));
newService.setName("myapp_aaa");
newService.setPort(port);
client.agentServiceRegister(newService);
}
}
und seine Arbeits innerhalb Docker Bildes. Ist das ein Fehler im Wildfly-Swarm-Topologiebruch oder fehlt mir eine Konfiguration?
EDIT 2: Ich habe festgestellt, dass das Problem mit Wildfly-Schwarm-Paramater -Djava.net.preferIPv4Stack=true
ist. Wenn ich jar-Datei mit diesem Parameter ausführen bekomme ich gleiche Ausnahme, aber wenn ich es Dockerfile entfernen für Docker Bild zu schaffen und führen Sie es bekomme ich diese Ausnahme:
2017-09-27 20:34:46,460 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) MSC000001: Failed to start service jboss.undertow.listener.default: org.jboss.msc.service.StartException in service jboss.undertow.listener.default: WFLYUT0082: Could not start 'default' listener.
at org.wildfly.extension.undertow.ListenerService.start(ListenerService.java:153)
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: java.net.SocketException: Protocol family unavailable
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:433)
at sun.nio.ch.Net.bind(Net.java:425)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
at org.xnio.nio.NioXnioWorker.createTcpConnectionServer(NioXnioWorker.java:171)
at org.xnio.XnioWorker.createStreamConnectionServer(XnioWorker.java:245)
at org.wildfly.extension.undertow.HttpListenerService.startListening(HttpListenerService.java:126)
at org.wildfly.extension.undertow.ListenerService.start(ListenerService.java:142)
... 5 more
Hier ist der Link zu GitHub Projekt, bei dem Sie den Fehler reproduzieren können : https://github.com/pkristja/wildfly-swarm-consul-demo
Im Docker Container, kann es http://172.30.3.80:8500 sehen? – Ken
Ja ist sichtbar. root @ d324822a2809:/# curl -v telnet: //172.30.3.80: 8500 * URL neu erstellt auf: telnet: //172.30.3.80: 8500/ * Probieren 172.30.3.80 ... * TCP_NODELAY set * Verbunden zu 172.30.3.80 (172.30.3.80) Port 8500 (# 0) – Kiki
@Ken Ich habe die Frage aktualisiert. Haben Sie neue Informationen oder sollte ich das Problem auf Wildfly-Swarm jira öffnen? – Kiki