Пустое имя хоста равноправного узла eureka при запуске (AWS включен) - PullRequest
0 голосов
/ 01 ноября 2019

Я изучаю процесс настройки Eureka в AWS ECS, к сожалению, документации не хватает, и в Интернете есть много предложений, которые приводят к путанице.

Я почти успешно запустил Eureka с ElasticIPs. Я беру их с Route53, когда он запускается, с этим сказано, что есть дубликат одноранговых узлов, один с пустым именем хоста, а другой с правильным Elastic IP, например:

2019-10-31 22:38:46.458  INFO 73 --- [           main] c.n.eureka.cluster.PeerEurekaNodes       : Adding new peer nodes [http://:8761/eureka/, http://ec2-XXX-XXX-XXX-233.compute-1.amazonaws.com:8761/eureka/]
2019-10-31 22:38:46.523  INFO 73 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON encoding codec LegacyJacksonJson
2019-10-31 22:38:46.539  INFO 73 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON decoding codec LegacyJacksonJson
2019-10-31 22:38:46.546  INFO 73 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using XML encoding codec XStreamXml
2019-10-31 22:38:46.548  INFO 73 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using XML decoding codec XStreamXml
2019-10-31 22:38:46.889  INFO 73 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON encoding codec LegacyJacksonJson
2019-10-31 22:38:46.900  INFO 73 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON decoding codec LegacyJacksonJson
2019-10-31 22:38:46.902  INFO 73 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using XML encoding codec XStreamXml
2019-10-31 22:38:46.904  INFO 73 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using XML decoding codec XStreamXml
2019-10-31 22:38:47.019  INFO 73 --- [           main] c.n.eureka.cluster.PeerEurekaNodes       : Replica node URL:  http://:8761/eureka/
2019-10-31 22:38:47.032  INFO 73 --- [           main] c.n.eureka.cluster.PeerEurekaNodes       : Replica node URL:  http://ec2-XXX-XXX-XXX-233.compute-1.amazonaws.com:8761/eureka/

Eureka запускается иЯ могу получить к нему доступ через 8761, но получаю ошибку шаблона:

2019-10-31 21:46:41.882 ERROR 1 --- [nio-8761-exec-2] freemarker.runtime                       : Error executing FreeMarker template

freemarker.core.InvalidReferenceException: The following has evaluated to null or missing:
==> replica.key  [in template "eureka/navbar.ftl" at line 68, column 62]

----
Tip: It's the step after the last dot that caused this error, not those before it.
----
Tip: If the failing expression is known to legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
----

----
FTL stack trace ("~" means nesting-related):
        - Failed at: ${replica.key}  [in template "eureka/navbar.ftl" at line 68, column 60]
        - Reached through: #include "navbar.ftl"  [in template "eureka/status.ftl" at line 22, column 7]
----
        at freemarker.core.InvalidReferenceException.getInstance(InvalidReferenceException.java:134) ~[freemarker-2.3.28.jar!/:2.3.28]
        at freemarker.core.EvalUtil.coerceModelToTextualCommon(EvalUtil.java:467) ~[freemarker-2.3.28.jar!/:2.3.28]
        at freemarker.core.EvalUtil.coerceModelToStringOrMarkup(EvalUtil.java:389) ~[freemarker-2.3.28.jar!/:2.3.28]
        at freemarker.core.EvalUtil.coerceModelToStringOrMarkup(EvalUtil.java:358) ~[freemarker-2.3.28.jar!/:2.3.28]
        at freemarker.core.DollarVariable.calculateInterpolatedStringOrMarkup(DollarVariable.java:100) ~[freemarker-2.3.28.jar!/:2.3.28]
        at freemarker.core.DollarVariable.accept(DollarVariable.java:63) ~[freemarker-2.3.28.jar!/:2.3.28]
        at freemarker.core.Environment.visit(Environment.java:366) [freemarker-2.3.28.jar!/:2.3.28]
        at freemarker.core.IteratorBlock$IterationContext.executedNestedContentForCollOrSeqListing(IteratorBlock.java:317) [freemarker-2.3.28.jar!/:2.3.28]
        at freemarker.core.IteratorBlock$IterationContext.executeNestedContent(IteratorBlock.java:271) [freemarker-2.3.28.jar!/:2.3.28]
        at freemarker.core.IteratorBlock$IterationContext.accept(IteratorBlock.java:242) [freemarker-2.3.28.jar!/:2.3.28]
        at freemarker.core.Environment.visitIteratorBlock(Environment.java:642) [freemarker-2.3.28.jar!/:2.3.28]
        at freemarker.core.IteratorBlock.acceptWithResult(IteratorBlock.java:107) [freemarker-2.3.28.jar!/:2.3.28]
        at freemarker.core.IteratorBlock.accept(IteratorBlock.java:93) [freemarker-2.3.28.jar!/:2.3.28]
        at freemarker.core.Environment.visit(Environment.java:330) [freemarker-2.3.28.jar!/:2.3.28]
        at freemarker.core.Environment.visit(Environment.java:336) [freemarker-2.3.28.jar!/:2.3.28]
        at freemarker.core.Environment.include(Environment.java:2582) [freemarker-2.3.28.jar!/:2.3.28]
        at freemarker.core.Include.accept(Include.java:171) [freemarker-2.3.28.jar!/:2.3.28]
        at freemarker.core.Environment.visit(Environment.java:330) [freemarker-2.3.28.jar!/:2.3.28]
        at freemarker.core.Environment.visit(Environment.java:336) [freemarker-2.3.28.jar!/:2.3.28]
        at freemarker.core.Environment.process(Environment.java:309) [freemarker-2.3.28.jar!/:2.3.28]
        at freemarker.template.Template.process(Template.java:384) [freemarker-2.3.28.jar!/:2.3.28]
        at org.springframework.web.servlet.view.freemarker.FreeMarkerView.processTemplate(FreeMarkerView.java:389) [spring-webmvc-5.1.8.RELEASE.jar!/:5.1.8.RELEASE]
        at org.springframework.web.servlet.view.freemarker.FreeMarkerView.doRender(FreeMarkerView.java:302) [spring-webmvc-5.1.8.RELEASE.jar!/:5.1.8.RELEASE]
        at org.springframework.web.servlet.view.freemarker.FreeMarkerView.renderMergedTemplateModel(FreeMarkerView.java:253) [spring-webmvc-5.1.8.RELEASE.jar!/:5.1.8.RELEASE]
        at org.springframework.web.servlet.view.AbstractTemplateView.renderMergedOutputModel(AbstractTemplateView.java:178) [spring-webmvc-5.1.8.RELEASE.jar!/:5.1.8.RELEASE]
        at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:316) [spring-webmvc-5.1.8.RELEASE.jar!/:5.1.8.RELEASE]
        at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1371) [spring-webmvc-5.1.8.RELEASE.jar!/:5.1.8.RELEASE]
        at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1117) [spring-webmvc-5.1.8.RELEASE.jar!/:5.1.8.RELEASE]
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1056) [spring-webmvc-5.1.8.RELEASE.jar!/:5.1.8.RELEASE]
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942) [spring-webmvc-5.1.8.RELEASE.jar!/:5.1.8.RELEASE]
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005) [spring-webmvc-5.1.8.RELEASE.jar!/:5.1.8.RELEASE]
        at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:897) [spring-webmvc-5.1.8.RELEASE.jar!/:5.1.8.RELEASE]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:634) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
        at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882) [spring-webmvc-5.1.8.RELEASE.jar!/:5.1.8.RELEASE]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) [tomcat-embed-websocket-9.0.21.jar!/:9.0.21]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
        at org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter.doFilterInternal(HttpTraceFilter.java:88) [spring-boot-actuator-2.1.6.RELEASE.jar!/:2.1.6.RELEASE]
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109) [spring-web-5.1.8.RELEASE.jar!/:5.1.8.RELEASE]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
        at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) [spring-web-5.1.8.RELEASE.jar!/:5.1.8.RELEASE]
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109) [spring-web-5.1.8.RELEASE.jar!/:5.1.8.RELEASE]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
        at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:92) [spring-web-5.1.8.RELEASE.jar!/:5.1.8.RELEASE]
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109) [spring-web-5.1.8.RELEASE.jar!/:5.1.8.RELEASE]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
        at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93) [spring-web-5.1.8.RELEASE.jar!/:5.1.8.RELEASE]
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109) [spring-web-5.1.8.RELEASE.jar!/:5.1.8.RELEASE]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
        at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:114) [spring-boot-actuator-2.1.6.RELEASE.jar!/:2.1.6.RELEASE]
        at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:104) [spring-boot-actuator-2.1.6.RELEASE.jar!/:2.1.6.RELEASE]
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109) [spring-web-5.1.8.RELEASE.jar!/:5.1.8.RELEASE]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
        at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) [spring-web-5.1.8.RELEASE.jar!/:5.1.8.RELEASE]
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109) [spring-web-5.1.8.RELEASE.jar!/:5.1.8.RELEASE]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:853) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1587) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
        at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_212]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_212]
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
        at java.lang.Thread.run(Thread.java:748) [na:1.8.0_212]

2019-10-31 21:46:41.917 ERROR 1 --- [nio-8761-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is freemarker.core.InvalidReferenceException: The following has evaluated to null or missing:
==> replica.key  [in template "eureka/navbar.ftl" at line 68, column 62]

Я попытался несколько конфигов без удачи, это мое приложение сервера eureka.properties

server.port=8761
spring.application.name=eureka
cloud.aws.stack.auto=false

eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false

eureka.client.service-url.default-zone=http://${eureka.instance.hostname}:${server.port}/eureka/

eureka.client.region=us-east-1
eureka.client.use-dns-for-fetching-service-urls=true
eureka.client.eureka-server-u-r-l-context=eureka
eureka.client.eureka-server-d-n-s-name=eureka.domain.com
eureka.client.eureka-server-port=8761

Я также попробовал следующие параметры для конфигурации Eureka без удачи:

(also tried:
- eureka.client.serviceUrl.defaultZone=
- eureka.client.service-url.us-east-1c=
And also tried values such as:
- http://localhost:8761/eureka/)

1 Ответ

0 голосов
/ 07 ноября 2019

Наконец-то исправил.

Проблема была в том, что я находился в записях TXT Route53, оставляя пробел в начале и конце в соответствии с предложением презентации (семинара, которого я сейчас не могу найти), и это вызвало проблемупосле удаления работает как надо.

...