Tag Archives: eureka client

[Solved] Eureka Startup Error: Root name (‘timestamp‘) does not match expected type EurekaApplications

Eureka Startup Error: Root name (‘timestamp‘) does not match expected type EurekaApplications

1. Eureka startup error

Recently, I was learning that Eureka started the client to report errors, and checked a bunch of fucking answers on the Internet

  • Some people say that the spring security csrf authentication control is turned on, you have to add a configuration to cancel the csrf authentication
    I see that my configuration does not introduce spring security package ah, where to open the login authentication, bullshit it
  • Some people say it is eureka url to add userName:password My eureka does not have a username password, should not be the problem here either

If you have introduced spring security and set login authentication to be added, the fundamental problem is not here

the error message is

Root name (‘timestamp’) does not match expected (‘applications’) for type EurekaApplications

Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Root name (‘timestamp’) does not match expected (‘applications’) for type org.springframework.cloud.netflix.eureka.http.EurekaApplications
at [Source: (org.springframework.util.StreamUtils$NonClosingInputStream); line: 1, column: 2] (through reference chain: org.springframework.cloud.netflix.eureka.http.EurekaApplications[“timestamp”])

 

Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Root name ('timestamp') does not match expected ('applications') for type `org.springframework.cloud.netflix.eureka.http.EurekaApplications`
 at [Source: (org.springframework.util.StreamUtils$NonClosingInputStream); line: 1, column: 2] (through reference chain: org.springframework.cloud.netflix.eureka.http.EurekaApplications["timestamp"])

2. Solutions

Eureka requires that the suffix end of your serviceurl must be Eureka
if you write something else, the above error will appear
what I write is http://localhost:${server.port}/eurekajzj is wrong

The server is consistent with the client http://localhost: ${server. Port}/Eureka will do

Otherwise, the above error will appear

3. Eureka server configuration

First, start the class eurekaserver
to see the configuration of the server

spring.application.name=eureka-server
server.port=8761

#eureka auto-preservation off
eureka.server.enable-self-preservation=false

eureka.instance.hostname=eureka-hostname-jzj
# Cannot call self
eureka.client.fetch-registry=false
#Does not register itself
eureka.client.register-with-eureka=false

eureka.client.service-url.defaultZone = http://localhost:${server.port}/eurekajzj

4. Eureka client configuration

server.port=8088

#user service
spring.application.name=user-client

#eureka
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eurekajzj

5. Problems

The problem is the eurekajzj suffix
The serviceUrl address of my Eureka Server configuration
eureka.client.service-url.defaultZone = http://localhost:${server.port}/eurekajzj
My client’s configured eureka address
eureka.client.serviceUrl.defaultZone = http://localhost:8761/eurekajzj
The suffix ending is not eureka

After modification, all Eureka services and clients are working fine

[Solved] Error in registering Eureka for spring cloud micro service: classnotfoundexception: org.apache.http.conn.scheme.schemeregistry

1. Problem description

As mentioned above, it is normal to start the Eureka server alone. When you start the micro service module and register the service with Eureka, an error is reported.

My microservice module POM depends on the following:

<dependencies>
        <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-web</artifactId>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>2.1.1</version>
        </dependency>

    </dependencies>

Microservice module configuration file:

eureka.client.service-url.defaultZone=http://localhost:8000/eureka

The total POM of the project is as follows:

<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</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>Greenwich.SR5</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

2. Solution

See a similar problem on stack overflow:

https://stackoverflow.com/questions/28217891/java-lang-classnotfoundexception-org-apache-http-config-registrybuilder

It is speculated that there may also be a problem with the dependent package under D: \ D1 \ Java \ maven \ repo \ ORG \ Apache \ httpcomponents

According to the time of the file modification date, the following package should be called for the use of Eureka

Delete these folders and reintroduce the POM dependency of microservice module and Eureka server

Start the microservice here and the problem is solved

16:31:17.183- INFO 38700 --- [           main]com.netflix.discovery.DiscoveryClient    :Getting all instance registry info from the eureka server
16:31:17.460- INFO 38700 --- [           main]com.netflix.discovery.DiscoveryClient    :The response status is 200
16:31:17.462- INFO 38700 --- [           main]com.netflix.discovery.DiscoveryClient    :Starting heartbeat executor: renew interval is: 30
16:31:17.465- INFO 38700 --- [           main]c.n.discovery.InstanceInfoReplicator     :InstanceInfoReplicator onDemand update allowed rate per min is 4
16:31:17.470- INFO 38700 --- [           main]com.netflix.discovery.DiscoveryClient    :Discovery Client initialized at timestamp 1628843477468 with initial instances count: 0
16:31:17.472- INFO 38700 --- [           main]o.s.c.n.e.s.EurekaServiceRegistry        :Registering application COURSE-LIST with eureka with status UP
16:31:17.472- INFO 38700 --- [           main]com.netflix.discovery.DiscoveryClient    :Saw local status change event StatusChangeEvent [timestamp=1628843477472, current=UP, previous=STARTING]
16:31:17.475- INFO 38700 --- [nfoReplicator-0]com.netflix.discovery.DiscoveryClient    :DiscoveryClient_COURSE-LIST/LAPTOP-LMMPH4VI:course-list:8080: registering service...
16:31:17.523- INFO 38700 --- [           main]o.s.b.w.embedded.tomcat.TomcatWebServer  :Tomcat started on port(s): 8080 (http) with context path ''
16:31:17.524- INFO 38700 --- [           main].s.c.n.e.s.EurekaAutoServiceRegistration :Updating port to 8080
16:31:17.567- INFO 38700 --- [nfoReplicator-0]com.netflix.discovery.DiscoveryClient    :DiscoveryClient_COURSE-LIST/LAPTOP-LMMPH4VI:course-list:8080 - registration status: 204
16:31:19.133- INFO 38700 --- [           main]com.fanyu.course.CourseListApplication   :Started CourseListApplication in 13.313 seconds (JVM running for 14.906)