Eureka Client is Unable to connect to Eureka Discovery Server when deployed on Stand alone Tomcat

79 views Asked by At

Just a brief summary of the Problem:

  • I had one Spring boot application in which I had a Eureka discovery server and Client.

  • When executed one IntelliJ or as a jar file the setup worked fine and the Eureka client was able to register to the Discovery Server.

  • Now I wanted those to be deployed on a Standalone Tomcat apache-tomcat-10.1.18-windows-x64.

  • So I converted these Jar files into war

  • The execution Setup for tomCat is like for Discovery Server

  • set JAVA_HOME=C:\Program Files\Java\jdk-17

  • set CATALINA_HOME=F:\software\tomcat\apache-tomcat

  • set CATALINA_BASE=F:\software\tomcat\DiscoverServer

  • F:\software\tomcat\apache-tomcat\bin\startup.bat enter image description here

  • The execution Setup for Discovery client

  • set JAVA_HOME=C:\Program Files\Java\jdk-17

  • set CATALINA_HOME=F:\software\tomcat\apache-tomcat

  • set CATALINA_BASE=F:\software\tomcat\client

  • F:\software\tomcat\apache-tomcat\bin\startup.bat enter image description here

Just to mention the client and DiscoverServer have only the respective config folder copied from tomcat with modified port name and the changes done to context path as mentioned above.

When start the discovery service it runs fine and launches on 8761 port. But when I run the client war it fails to register to the server. If I execute the same setup from intellij the client is able to register to the Discovery server but not registering when I try to deploy/execute on standalone tomcat.

Pom XML for Client

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.2.2</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.Discov</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>demo</name>
    <description>Demo project for Spring Boot</description>
    <packaging>war</packaging>
    <properties>
        <java.version>17</java.version>
        <spring-cloud.version>2023.0.0</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-client</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</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>
     <finalName>eurecatest</finalName>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

@SpringBootApplication
@EnableDiscoveryClient
public class DemoApplication{


    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }

}
public class ServletInitializer extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(DemoApplication.class);
    }
}

Application.properties

eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka
server.port =0
spring.application.name=eurekaClient

snippnet of Server.XMl for Discovery Server


    <Connector port="8761" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443"
               maxParameterCount="1000"
               />

      <Context path="/"
                docBase = "F:\Learning\Projects\AccountingPostingFramework\discoveryServer\target\discoveryServer.war"/>    



for client


    <Connector port="8762" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443"
               maxParameterCount="1000"
               />
    
    

      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
        <Context path="/exchangeRate"
                docBase = "C:\Users\Bhartipandit\Desktop\eurekaClient\OldVersion\demo\target\eurecatest.war"/>      

        
      </Host>


Log on Starting the Client


2024-01-23T23:27:22.424+05:30  INFO 20360 --- [eurekaClient] [           main] com.Discov.demo.ServletInitializer       : Starting ServletInitializer v0.0.1-SNAPSHOT using Java 17 with PID 20360 (F:\software\tomcat\exchnageRate\webapps\exchangeRate\WEB-INF\classes started by Bhartipandit in F:\software\tomcat)
2024-01-23T23:27:22.433+05:30  INFO 20360 --- [eurekaClient] [           main] com.Discov.demo.ServletInitializer       : No active profile set, falling back to 1 default profile: "default"
2024-01-23T23:27:25.792+05:30  INFO 20360 --- [eurekaClient] [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=8e4081eb-3adb-3507-9f49-8b8b3df7a11a
2024-01-23T23:27:26.012+05:30  WARN 20360 --- [eurekaClient] [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.client.loadbalancer.LoadBalancerAutoConfiguration$LoadBalancerInterceptorConfig' of type [org.springframework.cloud.client.loadbalancer.LoadBalancerAutoConfiguration$LoadBalancerInterceptorConfig] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). The currently created BeanPostProcessor [lbRestClientPostProcessor] is declared through a non-static factory method on that class; consider declaring it as static instead.
2024-01-23T23:27:26.035+05:30  WARN 20360 --- [eurekaClient] [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.loadbalancer.config.BlockingLoadBalancerClientAutoConfiguration' of type [org.springframework.cloud.loadbalancer.config.BlockingLoadBalancerClientAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [lbRestClientPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.
2024-01-23T23:27:26.048+05:30  WARN 20360 --- [eurekaClient] [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.loadbalancer.config.LoadBalancerAutoConfiguration' of type [org.springframework.cloud.loadbalancer.config.LoadBalancerAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [lbRestClientPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.
2024-01-23T23:27:26.109+05:30  WARN 20360 --- [eurekaClient] [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.commons.config.CommonsConfigAutoConfiguration' of type [org.springframework.cloud.commons.config.CommonsConfigAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [lbRestClientPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.
2024-01-23T23:27:26.117+05:30  WARN 20360 --- [eurekaClient] [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.client.loadbalancer.LoadBalancerDefaultMappingsProviderAutoConfiguration' of type [org.springframework.cloud.client.loadbalancer.LoadBalancerDefaultMappingsProviderAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [lbRestClientPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.
2024-01-23T23:27:26.122+05:30  WARN 20360 --- [eurekaClient] [           main] trationDelegate$BeanPostProcessorChecker : Bean 'loadBalancerClientsDefaultsMappingsProvider' of type [org.springframework.cloud.client.loadbalancer.LoadBalancerDefaultMappingsProviderAutoConfiguration$$Lambda$511/0x0000000800fd9960] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [lbRestClientPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.
2024-01-23T23:27:26.127+05:30  WARN 20360 --- [eurekaClient] [           main] trationDelegate$BeanPostProcessorChecker : Bean 'defaultsBindHandlerAdvisor' of type [org.springframework.cloud.commons.config.DefaultsBindHandlerAdvisor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [lbRestClientPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.
2024-01-23T23:27:26.242+05:30  WARN 20360 --- [eurekaClient] [           main] trationDelegate$BeanPostProcessorChecker : Bean 'spring.cloud.loadbalancer-org.springframework.cloud.client.loadbalancer.LoadBalancerClientsProperties' of type [org.springframework.cloud.client.loadbalancer.LoadBalancerClientsProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [lbRestClientPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.
2024-01-23T23:27:26.280+05:30  WARN 20360 --- [eurekaClient] [           main] trationDelegate$BeanPostProcessorChecker : Bean 'default.org.springframework.cloud.loadbalancer.config.LoadBalancerAutoConfiguration.LoadBalancerClientSpecification' of type [org.springframework.cloud.loadbalancer.annotation.LoadBalancerClientSpecification] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [lbRestClientPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.
2024-01-23T23:27:26.282+05:30  WARN 20360 --- [eurekaClient] [           main] trationDelegate$BeanPostProcessorChecker : Bean 'default.org.springframework.cloud.loadbalancer.config.BlockingLoadBalancerClientAutoConfiguration.LoadBalancerClientSpecification' of type [org.springframework.cloud.loadbalancer.annotation.LoadBalancerClientSpecification] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [lbRestClientPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.
2024-01-23T23:27:26.285+05:30  WARN 20360 --- [eurekaClient] [           main] trationDelegate$BeanPostProcessorChecker : Bean 'default.org.springframework.cloud.netflix.eureka.loadbalancer.LoadBalancerEurekaAutoConfiguration.LoadBalancerClientSpecification' of type [org.springframework.cloud.loadbalancer.annotation.LoadBalancerClientSpecification] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [lbRestClientPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.
2024-01-23T23:27:26.291+05:30  WARN 20360 --- [eurekaClient] [           main] trationDelegate$BeanPostProcessorChecker : Bean 'loadBalancerClientFactory' of type [org.springframework.cloud.loadbalancer.support.LoadBalancerClientFactory] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [lbRestClientPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.
2024-01-23T23:27:26.315+05:30  WARN 20360 --- [eurekaClient] [           main] trationDelegate$BeanPostProcessorChecker : Bean 'blockingLoadBalancerClient' of type [org.springframework.cloud.loadbalancer.blocking.client.BlockingLoadBalancerClient] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [lbRestClientPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.
2024-01-23T23:27:26.353+05:30  WARN 20360 --- [eurekaClient] [           main] trationDelegate$BeanPostProcessorChecker : Bean 'loadBalancerServiceInstanceCookieTransformer' of type [org.springframework.cloud.loadbalancer.core.LoadBalancerServiceInstanceCookieTransformer] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [lbRestClientPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.
2024-01-23T23:27:26.357+05:30  WARN 20360 --- [eurekaClient] [           main] trationDelegate$BeanPostProcessorChecker : Bean 'xForwarderHeadersTransformer' of type [org.springframework.cloud.loadbalancer.blocking.XForwardedHeadersTransformer] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [lbRestClientPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.
2024-01-23T23:27:26.361+05:30  WARN 20360 --- [eurekaClient] [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.client.loadbalancer.LoadBalancerAutoConfiguration' of type [org.springframework.cloud.client.loadbalancer.LoadBalancerAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [lbRestClientPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.
2024-01-23T23:27:26.367+05:30  WARN 20360 --- [eurekaClient] [           main] trationDelegate$BeanPostProcessorChecker : Bean 'loadBalancerRequestFactory' of type [org.springframework.cloud.client.loadbalancer.LoadBalancerRequestFactory] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [lbRestClientPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.
2024-01-23T23:27:26.375+05:30  WARN 20360 --- [eurekaClient] [           main] trationDelegate$BeanPostProcessorChecker : Bean 'loadBalancerInterceptor' of type [org.springframework.cloud.client.loadbalancer.LoadBalancerInterceptor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [lbRestClientPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.
2024-01-23T23:27:26.408+05:30  INFO 20360 --- [eurekaClient] [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 3767 ms
2024-01-23T23:27:29.637+05:30  INFO 20360 --- [eurekaClient] [           main] DiscoveryClientOptionalArgsConfiguration : Eureka HTTP Client uses RestTemplate.
2024-01-23T23:27:29.973+05:30  WARN 20360 --- [eurekaClient] [           main] iguration$LoadBalancerCaffeineWarnLogger : Spring Cloud LoadBalancer is currently working with the default cache. While this cache implementation is useful for development and tests, it's recommended to use Caffeine cache in production.You can switch to using Caffeine cache, by adding it and org.springframework.cache.caffeine.CaffeineCacheManager to the classpath.
2024-01-23T23:27:30.078+05:30  INFO 20360 --- [eurekaClient] [           main] com.Discov.demo.ServletInitializer       : Started ServletInitializer in 9.911 seconds (process running for 29.537)
23-Jan-2024 23:27:30.215 WARNING [main] org.apache.catalina.util.SessionIdGeneratorBase.createSecureRandom Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [108] milliseconds.
23-Jan-2024 23:27:30.289 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8762"]23-Jan-2024 23:27:30.419 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [24147] milliseconds

As you can see it is very simple client But I am not sure what is causing the issue for it to register to the Discovery server when trying to deploy on Standalone Tomcat. The Eureka client should be able to register on Discovery server both when deployed on standalone Tomcat.

Note: The Client is able to connect on Discovery server deployed on standalone when client is executed ad Jar.

0

There are 0 answers