I have configured eureka server app and deployed successfully on standalone tomcat server as war file, but I have an error in client app during registration it in eureka server while deploying client war on standalone tomcat.
Eureka Server (tomcat is running on localhost:8080, eureka dashboard is accessible) application.properties
spring.application.name=eureka
server.port=8080
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
Application class
@SpringBootApplication
@EnableEurekaServer
public class SpringEurekaServerApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(SpringEurekaServerApplication.class);
}
public static void main(String[] args) {
SpringApplication.run(SpringEurekaServerApplication.class, args);
}
}
Eureka client (tomcat is running on localhost:8081) application.properties
spring.application.name=gallery-service
server.port=8081
eureka.client.service-url.default-zone=http://localhost:8080/eureka
Application class
@SpringBootApplication
@EnableEurekaClient
public class SpringEurekaGalleryApp extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(SpringEurekaGalleryApp.class);
}
public static void main(String[] args) {
SpringApplication.run(SpringEurekaGalleryApp.class, args);
}
}
Eureka server pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.eureka.server</groupId>
<artifactId>spring-eureka-server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>spring-eureka-server</name>
<description>Demo project for Spring Boot Cloud</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
<relativePath/>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Finchley.M9</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</project>
Eureka client pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.eureka.student</groupId>
<artifactId>spring-eureka-student</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>spring-eureka-student</name>
<description>Demo project for Spring Boot Cloud</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
<relativePath/>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Finchley.M9</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</project>
Here is the error stack trace
2019-03-23 20:54:10.893 INFO 26379 --- [ost-startStop-1] o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase 0
2019-03-23 20:54:10.905 INFO 26379 --- [ost-startStop-1] o.s.c.n.eureka.InstanceInfoFactory : Setting initial instance status as: STARTING
2019-03-23 20:54:10.972 INFO 26379 --- [ost-startStop-1] com.netflix.discovery.DiscoveryClient : Initializing Eureka in region us-east-1
2019-03-23 20:54:11.144 INFO 26379 --- [ost-startStop-1] c.n.d.provider.DiscoveryJerseyProvider : Using JSON encoding codec LegacyJacksonJson
2019-03-23 20:54:11.144 INFO 26379 --- [ost-startStop-1] c.n.d.provider.DiscoveryJerseyProvider : Using JSON decoding codec LegacyJacksonJson
2019-03-23 20:54:11.483 INFO 26379 --- [ost-startStop-1] c.n.d.provider.DiscoveryJerseyProvider : Using XML encoding codec XStreamXml
2019-03-23 20:54:11.483 INFO 26379 --- [ost-startStop-1] c.n.d.provider.DiscoveryJerseyProvider : Using XML decoding codec XStreamXml
2019-03-23 20:54:11.717 INFO 26379 --- [ost-startStop-1] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration
2019-03-23 20:54:11.746 INFO 26379 --- [ost-startStop-1] com.netflix.discovery.DiscoveryClient : Disable delta property : false
2019-03-23 20:54:11.746 INFO 26379 --- [ost-startStop-1] com.netflix.discovery.DiscoveryClient : Single vip registry refresh property : null
2019-03-23 20:54:11.747 INFO 26379 --- [ost-startStop-1] com.netflix.discovery.DiscoveryClient : Force full registry fetch : false
2019-03-23 20:54:11.747 INFO 26379 --- [ost-startStop-1] com.netflix.discovery.DiscoveryClient : Application is null : false
2019-03-23 20:54:11.747 INFO 26379 --- [ost-startStop-1] com.netflix.discovery.DiscoveryClient : Registered Applications size is zero : true
2019-03-23 20:54:11.747 INFO 26379 --- [ost-startStop-1] com.netflix.discovery.DiscoveryClient : Application version is -1: true
2019-03-23 20:54:11.747 INFO 26379 --- [ost-startStop-1] com.netflix.discovery.DiscoveryClient : Getting all instance registry info from the eureka server
2019-03-23 20:54:11.862 ERROR 26379 --- [ost-startStop-1] c.n.d.s.t.d.RedirectingEurekaHttpClient : Request execution error
com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused (Connection refused)
at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:187) ~[ApacheHttpClient4Handler.class:1.19.1]
at com.sun.jersey.api.client.filter.GZIPContentEncodingFilter.handle(GZIPContentEncodingFilter.java:123) ~[GZIPContentEncodingFilter.class:1.19.1]
at com.netflix.discovery.EurekaIdentityHeaderFilter.handle(EurekaIdentityHeaderFilter.java:27) ~[EurekaIdentityHeaderFilter.class:1.8.7]
at com.sun.jersey.api.client.Client.handle(Client.java:652) ~[Client.class:1.19.1]
at com.sun.jersey.api.client.WebResource.handle(WebResource.java:682) ~[WebResource.class:1.19.1]
at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74) ~[WebResource.class:1.19.1]
at com.sun.jersey.api.client.WebResource$Builder.get(WebResource.java:509) ~[WebResource$Builder.class:1.19.1]
at com.netflix.discovery.shared.transport.jersey.AbstractJerseyEurekaHttpClient.getApplicationsInternal(AbstractJerseyEurekaHttpClient.java:194) ~[AbstractJerseyEurekaHttpClient.class:1.8.7]
at com.netflix.discovery.shared.transport.jersey.AbstractJerseyEurekaHttpClient.getApplications(AbstractJerseyEurekaHttpClient.java:165) ~[AbstractJerseyEurekaHttpClient.class:1.8.7]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$6.execute(EurekaHttpClientDecorator.java:137) [EurekaHttpClientDecorator$6.class:1.8.7]
at com.netflix.discovery.shared.transport.decorator.MetricsCollectingEurekaHttpClient.execute(MetricsCollectingEurekaHttpClient.java:73) ~[MetricsCollectingEurekaHttpClient.class:1.8.7]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.getApplications(EurekaHttpClientDecorator.java:134) [EurekaHttpClientDecorator.class:1.8.7]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$6.execute(EurekaHttpClientDecorator.java:137) [EurekaHttpClientDecorator$6.class:1.8.7]
at com.netflix.discovery.shared.transport.decorator.RedirectingEurekaHttpClient.executeOnNewServer(RedirectingEurekaHttpClient.java:118) ~[RedirectingEurekaHttpClient.class:1.8.7]
at com.netflix.discovery.shared.transport.decorator.RedirectingEurekaHttpClient.execute(RedirectingEurekaHttpClient.java:79) ~[RedirectingEurekaHttpClient.class:1.8.7]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.getApplications(EurekaHttpClientDecorator.java:134) [EurekaHttpClientDecorator.class:1.8.7]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$6.execute(EurekaHttpClientDecorator.java:137) [EurekaHttpClientDecorator$6.class:1.8.7]
at com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.execute(RetryableEurekaHttpClient.java:120) [RetryableEurekaHttpClient.class:1.8.7]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.getApplications(EurekaHttpClientDecorator.java:134) [EurekaHttpClientDecorator.class:1.8.7]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$6.execute(EurekaHttpClientDecorator.java:137) [EurekaHttpClientDecorator$6.class:1.8.7]
at com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.execute(SessionedEurekaHttpClient.java:77) [SessionedEurekaHttpClient.class:1.8.7]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.getApplications(EurekaHttpClientDecorator.java:134) [EurekaHttpClientDecorator.class:1.8.7]
at com.netflix.discovery.DiscoveryClient.getAndStoreFullRegistry(DiscoveryClient.java:1051) [DiscoveryClient.class:1.8.7]
at com.netflix.discovery.DiscoveryClient.fetchRegistry(DiscoveryClient.java:965) [DiscoveryClient.class:1.8.7]
at com.netflix.discovery.DiscoveryClient.<init>(DiscoveryClient.java:414) [DiscoveryClient.class:1.8.7]
at com.netflix.discovery.DiscoveryClient.<init>(DiscoveryClient.java:269) [DiscoveryClient.class:1.8.7]
at org.springframework.cloud.netflix.eureka.CloudEurekaClient.<init>(CloudEurekaClient.java:63) [CloudEurekaClient.class:2.0.0.M8]
at org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration.eurekaClient(EurekaClientAutoConfiguration.java:269) [EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration.class:2.0.0.M8]
at org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration$$EnhancerBySpringCGLIB$$daa31830.CGLIB$eurekaClient$0(<generated>) [EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration.class:2.0.0.M8]
at org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration$$EnhancerBySpringCGLIB$$daa31830$$FastClassBySpringCGLIB$$d23b36b5.invoke(<generated>) [EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration.class:2.0.0.M8]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) [MethodProxy.class:5.0.4.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361) [ConfigurationClassEnhancer$BeanMethodInterceptor.class:5.0.4.RELEASE]
at org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration$$EnhancerBySpringCGLIB$$daa31830.eurekaClient(<generated>) [EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration.class:2.0.0.M8]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_201]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_201]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_201]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_201]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) [SimpleInstantiationStrategy.class:5.0.4.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:579) [ConstructorResolver.class:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1250) [AbstractAutowireCapableBeanFactory.class:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1099) [AbstractAutowireCapableBeanFactory.class:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) [AbstractAutowireCapableBeanFactory.class:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502) [AbstractAutowireCapableBeanFactory.class:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$1(AbstractBeanFactory.java:348) [AbstractBeanFactory.class:5.0.4.RELEASE]
at org.springframework.cloud.context.scope.GenericScope$BeanLifecycleWrapper.getBean(GenericScope.java:384) ~[GenericScope$BeanLifecycleWrapper.class:2.0.0.M9]
at org.springframework.cloud.context.scope.GenericScope.get(GenericScope.java:183) ~[GenericScope.class:2.0.0.M9]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:345) [AbstractBeanFactory.class:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) [AbstractBeanFactory.class:5.0.4.RELEASE]
at org.springframework.aop.target.SimpleBeanTargetSource.getTarget(SimpleBeanTargetSource.java:35) ~[SimpleBeanTargetSource.class:5.0.4.RELEASE]
at org.springframework.cloud.netflix.eureka.serviceregistry.EurekaRegistration.getTargetObject(EurekaRegistration.java:167) ~[EurekaRegistration.class:2.0.0.M8]
at org.springframework.cloud.netflix.eureka.serviceregistry.EurekaRegistration.getEurekaClient(EurekaRegistration.java:156) ~[EurekaRegistration.class:2.0.0.M8]
at org.springframework.cloud.netflix.eureka.serviceregistry.EurekaServiceRegistry.maybeInitializeClient(EurekaServiceRegistry.java:57) ~[EurekaServiceRegistry.class:2.0.0.M8]
at org.springframework.cloud.netflix.eureka.serviceregistry.EurekaServiceRegistry.register(EurekaServiceRegistry.java:39) ~[EurekaServiceRegistry.class:2.0.0.M8]
at org.springframework.cloud.netflix.eureka.serviceregistry.EurekaAutoServiceRegistration.start(EurekaAutoServiceRegistration.java:80) ~[EurekaAutoServiceRegistration.class:2.0.0.M8]
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:181) ~[DefaultLifecycleProcessor.class:5.0.4.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:52) ~[DefaultLifecycleProcessor.class:5.0.4.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356) ~[DefaultLifecycleProcessor$LifecycleGroup.class:5.0.4.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:157) ~[DefaultLifecycleProcessor.class:5.0.4.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:121) ~[DefaultLifecycleProcessor.class:5.0.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:884) ~[AbstractApplicationContext.class:5.0.4.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:161) ~[ServletWebServerApplicationContext.class:2.0.0.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:552) ~[AbstractApplicationContext.class:5.0.4.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[ServletWebServerApplicationContext.class:2.0.0.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752) ~[SpringApplication.class:2.0.0.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:388) ~[SpringApplication.class:2.0.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) ~[SpringApplication.class:2.0.0.RELEASE]
at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:155) ~[SpringBootServletInitializer.class:2.0.0.RELEASE]
at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:135) ~[SpringBootServletInitializer.class:2.0.0.RELEASE]
at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:87) ~[SpringBootServletInitializer.class:2.0.0.RELEASE]
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:172) ~[SpringServletContainerInitializer.class:5.0.4.RELEASE]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5147) ~[catalina.jar:8.0.3]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[catalina.jar:8.0.3]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1387) ~[catalina.jar:8.0.3]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1377) ~[catalina.jar:8.0.3]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_201]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_201]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_201]
at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_201]
Caused by: java.net.ConnectException: Connection refused (Connection refused)
at java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:1.8.0_201]
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[na:1.8.0_201]
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_201]
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_201]
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_201]
at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_201]
at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:121) ~[PlainSocketFactory.class:4.5.5]
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:180) ~[DefaultClientConnectionOperator.class:4.5.5]
at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:144) ~[AbstractPoolEntry.class:4.5.5]
at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:134) ~[AbstractPooledConnAdapter.class:4.5.5]
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:610) ~[DefaultRequestDirector.class:4.5.5]
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:445) ~[DefaultRequestDirector.class:4.5.5]
at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:835) ~[AbstractHttpClient.class:4.5.5]
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:118) ~[CloseableHttpClient.class:4.5.5]
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56) ~[CloseableHttpClient.class:4.5.5]
at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:173) ~[ApacheHttpClient4Handler.class:1.19.1]
... 77 common frames omitted
2019-03-23 20:54:11.863 WARN 26379 --- [ost-startStop-1] c.n.d.s.t.d.RetryableEurekaHttpClient : Request execution failed with message: java.net.ConnectException: Connection refused (Connection refused)
2019-03-23 20:54:11.865 ERROR 26379 --- [ost-startStop-1] com.netflix.discovery.DiscoveryClient : DiscoveryClient_GALLERY-SERVICE/lenovo.Dlink:gallery-service:8081 - was unable to refresh its cache! status = Cannot execute request on any known server
com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server
at com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.execute(RetryableEurekaHttpClient.java:112) ~[RetryableEurekaHttpClient.class:1.8.7]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.getApplications(EurekaHttpClientDecorator.java:134) ~[EurekaHttpClientDecorator.class:1.8.7]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$6.execute(EurekaHttpClientDecorator.java:137) ~[EurekaHttpClientDecorator$6.class:1.8.7]
at com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.execute(SessionedEurekaHttpClient.java:77) ~[SessionedEurekaHttpClient.class:1.8.7]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.getApplications(EurekaHttpClientDecorator.java:134) ~[EurekaHttpClientDecorator.class:1.8.7]
at com.netflix.discovery.DiscoveryClient.getAndStoreFullRegistry(DiscoveryClient.java:1051) [DiscoveryClient.class:1.8.7]
at com.netflix.discovery.DiscoveryClient.fetchRegistry(DiscoveryClient.java:965) [DiscoveryClient.class:1.8.7]
at com.netflix.discovery.DiscoveryClient.<init>(DiscoveryClient.java:414) [DiscoveryClient.class:1.8.7]
at com.netflix.discovery.DiscoveryClient.<init>(DiscoveryClient.java:269) [DiscoveryClient.class:1.8.7]
at org.springframework.cloud.netflix.eureka.CloudEurekaClient.<init>(CloudEurekaClient.java:63) [CloudEurekaClient.class:2.0.0.M8]
at org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration.eurekaClient(EurekaClientAutoConfiguration.java:269) [EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration.class:2.0.0.M8]
at org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration$$EnhancerBySpringCGLIB$$daa31830.CGLIB$eurekaClient$0(<generated>) [EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration.class:2.0.0.M8]
at org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration$$EnhancerBySpringCGLIB$$daa31830$$FastClassBySpringCGLIB$$d23b36b5.invoke(<generated>) [EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration.class:2.0.0.M8]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) [MethodProxy.class:5.0.4.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361) [ConfigurationClassEnhancer$BeanMethodInterceptor.class:5.0.4.RELEASE]
at org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration$$EnhancerBySpringCGLIB$$daa31830.eurekaClient(<generated>) [EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration.class:2.0.0.M8]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_201]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_201]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_201]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_201]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) [SimpleInstantiationStrategy.class:5.0.4.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:579) [ConstructorResolver.class:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1250) [AbstractAutowireCapableBeanFactory.class:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1099) [AbstractAutowireCapableBeanFactory.class:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) [AbstractAutowireCapableBeanFactory.class:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502) [AbstractAutowireCapableBeanFactory.class:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$1(AbstractBeanFactory.java:348) [AbstractBeanFactory.class:5.0.4.RELEASE]
at org.springframework.cloud.context.scope.GenericScope$BeanLifecycleWrapper.getBean(GenericScope.java:384) ~[GenericScope$BeanLifecycleWrapper.class:2.0.0.M9]
at org.springframework.cloud.context.scope.GenericScope.get(GenericScope.java:183) ~[GenericScope.class:2.0.0.M9]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:345) [AbstractBeanFactory.class:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) [AbstractBeanFactory.class:5.0.4.RELEASE]
at org.springframework.aop.target.SimpleBeanTargetSource.getTarget(SimpleBeanTargetSource.java:35) ~[SimpleBeanTargetSource.class:5.0.4.RELEASE]
at org.springframework.cloud.netflix.eureka.serviceregistry.EurekaRegistration.getTargetObject(EurekaRegistration.java:167) ~[EurekaRegistration.class:2.0.0.M8]
at org.springframework.cloud.netflix.eureka.serviceregistry.EurekaRegistration.getEurekaClient(EurekaRegistration.java:156) ~[EurekaRegistration.class:2.0.0.M8]
at org.springframework.cloud.netflix.eureka.serviceregistry.EurekaServiceRegistry.maybeInitializeClient(EurekaServiceRegistry.java:57) ~[EurekaServiceRegistry.class:2.0.0.M8]
at org.springframework.cloud.netflix.eureka.serviceregistry.EurekaServiceRegistry.register(EurekaServiceRegistry.java:39) ~[EurekaServiceRegistry.class:2.0.0.M8]
at org.springframework.cloud.netflix.eureka.serviceregistry.EurekaAutoServiceRegistration.start(EurekaAutoServiceRegistration.java:80) ~[EurekaAutoServiceRegistration.class:2.0.0.M8]
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:181) ~[DefaultLifecycleProcessor.class:5.0.4.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:52) ~[DefaultLifecycleProcessor.class:5.0.4.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356) ~[DefaultLifecycleProcessor$LifecycleGroup.class:5.0.4.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:157) ~[DefaultLifecycleProcessor.class:5.0.4.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:121) ~[DefaultLifecycleProcessor.class:5.0.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:884) ~[AbstractApplicationContext.class:5.0.4.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:161) ~[ServletWebServerApplicationContext.class:2.0.0.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:552) ~[AbstractApplicationContext.class:5.0.4.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[ServletWebServerApplicationContext.class:2.0.0.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752) ~[SpringApplication.class:2.0.0.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:388) ~[SpringApplication.class:2.0.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) ~[SpringApplication.class:2.0.0.RELEASE]
at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:155) ~[SpringBootServletInitializer.class:2.0.0.RELEASE]
at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:135) ~[SpringBootServletInitializer.class:2.0.0.RELEASE]
at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:87) ~[SpringBootServletInitializer.class:2.0.0.RELEASE]
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:172) ~[SpringServletContainerInitializer.class:5.0.4.RELEASE]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5147) ~[catalina.jar:8.0.3]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[catalina.jar:8.0.3]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1387) ~[catalina.jar:8.0.3]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1377) ~[catalina.jar:8.0.3]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_201]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_201]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_201]
at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_201]
2019-03-23 20:54:11.865 WARN 26379 --- [ost-startStop-1] com.netflix.discovery.DiscoveryClient : Using default backup registry implementation which does not do anything.
2019-03-23 20:54:11.868 INFO 26379 --- [ost-startStop-1] com.netflix.discovery.DiscoveryClient : Starting heartbeat executor: renew interval is: 30
2019-03-23 20:54:11.873 INFO 26379 --- [ost-startStop-1] c.n.discovery.InstanceInfoReplicator : InstanceInfoReplicator onDemand update allowed rate per min is 4
2019-03-23 20:54:11.877 INFO 26379 --- [ost-startStop-1] com.netflix.discovery.DiscoveryClient : Discovery Client initialized at timestamp 1553367251876 with initial instances count: 0
2019-03-23 20:54:11.882 INFO 26379 --- [ost-startStop-1] o.s.c.n.e.s.EurekaServiceRegistry : Registering application gallery-service with eureka with status UP
2019-03-23 20:54:11.884 INFO 26379 --- [ost-startStop-1] com.netflix.discovery.DiscoveryClient : Saw local status change event StatusChangeEvent [timestamp=1553367251884, current=UP, previous=STARTING]
2019-03-23 20:54:11.887 INFO 26379 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_GALLERY-SERVICE/lenovo.Dlink:gallery-service:8081: registering service...
Comment From: spencergibb
Is eureka deployed in the root context?
Comment From: psergiychuk
eureka is deployed at http://localhost:8080/eureka/, I can access dashboard
Comment From: spencergibb
Your eureka client configuration expects eureka at the root. You need /eureka/eureka
Comment From: psergiychuk
I have set
eureka.client.service-url.default-zone=http://localhost:8080/eureka/eureka
on eureka client but error is the same
Comment From: ryanjbaxter
Can you provide a complete, minimal, verifiable sample that reproduces the problem? It should be available as a GitHub (or similar) project or attached to this issue as a zip file.
Comment From: psergiychuk
eureka.zip Here is code sample
Comment From: dsyer
The server will log the same error actually, if you enable eureka client there. So a minimal sample to reproduce it just
@SpringBootApplication
@EnableEurekaServer
public class EurekaApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaApplication.class, args);
}
}
with
server.port=8761
Comment From: vikramkhot111
same isuue on external tomcat
Comment From: xwaldornx
so is there a solution for this? i have the same issue on an external tomcat.
Comment From: OLPMO
The server will log the same error actually, if you enable eureka client there. So a minimal sample to reproduce it just
```java @SpringBootApplication @EnableEurekaServer public class EurekaApplication {
public static void main(String[] args) { SpringApplication.run(EurekaApplication.class, args); }
} ```
with
server.port=8761I want to confirm that Which type of server is this sample running on, embeded tomcat or standalone tomcat? @dsyer
Comment From: dsyer
I meant: if you run that as a war (not embedded). The context path is not “/“ by default in that case.
Comment From: dsyer
The solution (as far as we know) is to configure the client with the correct url for the server (including the context root).
Comment From: OLPMO
I run the eureka server as a war( named as eureka.war) in tomcat(version:9.0.14) on port 8080 with the application.properties as same as the sample provided by the author.And then I create a minimal eureka client and set eureka.client.service-url.defaultZone=http://localhost:8080/eureka/eureka.The running result proved that all is well.I can see the instance of client in the server dashboard. So, what confused me is that what is the bug of this issue?
Comment From: dilagurung
I run the eureka server as a war( named as eureka.war) in tomcat(version:9.0.14) on port 8080 with the application.properties as same as the sample provided by the author.And then I create a minimal eureka client and set eureka.client.service-url.defaultZone=http://localhost:8080/eureka/eureka.The running result proved that all is well.I can see the instance of client in the server dashboard. So, what confused me is that what is the bug of this issue?
No its not working. Do you have any sample, where eureka server is accessible once it is deployed to external tomcat?
Comment From: dilagurung
The solution is to 1. Remove the ROOT directory under /webapps. 2. Copy and paste the .war file in /webapps directory and rename it to ROOT.war 3. Access the registry from microservice by setting eureka.client.service-url.defaultZone=http://IP_ADDRESS:8080/eureka (Since my tomcat runs on port 8080, so the port is 8080 there).
I think the issue should be closed now