micronaut-projects / micronaut-discovery-client

Micronaut's Discovery Client
Apache License 2.0
22 stars 20 forks source link

Eureka Client GraalVM error #264

Open aaron-sr opened 3 years ago

aaron-sr commented 3 years ago

Hi,

I configured a micronaut service to connect to Eureka which works fine for a regular Java package. But if I package it via docker-native as a GraalVM image, the microservice throw constantly exceptions at runtime.

``` 13:02:08.386 [default-nioEventLoopGroup-1-19] ERROR i.m.m.health.indicator.HealthResult - Health indicator [eureka] reported exception: io.micronaut.http.client.exceptions.HttpClientResponseException: Error decoding HTTP response body: Error decoding stream for type [class io.micronaut.discovery.eureka.client.v2.AbstractEurekaClient$Applicatio nInfos]: Cannot construct instance of `io.micronaut.discovery.eureka.client.v2.AbstractEurekaClient$ApplicationInfos` (no Creators, like default constructor, exist): cannot deserialize from Object value (no delegate- or property-based Creator) at [Source: (byte[])"{"applications":{"versions__delta":"1","apps__hashcode":"DOWN_1_UP_1_","application":[{"name":"MODULE1","instance":[{"instanceId":"module1:8080","hostName":"module1-001","app":"MODULE1","ipAddr":"172.20.0.5","status":"DOWN","overriddenStatus":"DOWN","port":{"$":8080,"@enabled":"true"},"securePort":{"$":0,"@enabled":"false"}," countryId":1,"dataCenterInfo":{"@class":"com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo","name":"MyOwn"},"leaseInfo":{"renewalIntervalInSecs":30,"durationInSecs":90,"reg"[truncated 1612 bytes]; line: 1, column: 18] io.micronaut.http.client.exceptions.HttpClientResponseException: Error decoding HTTP response body: Error decoding stream for type [class io.micronaut.discovery.eureka.client.v2.AbstractEurekaClient$ApplicationInfos]: Cannot construct instance of `io.micronaut.discovery.eureka.client.v2.AbstractEurekaClient$ApplicationInfos` (no Creators, like default constructor, exist): cannot deserialize from Object value (no delegate- or property-based Creator) at [Source: (byte[])"{"applications":{"versions__delta":"1","apps__hashcode":"DOWN_1_UP_1_","application":[{"name":"MODULE1","instance":[{"instanceId":"module1:8080","hostName":"module1-001","app":"MODULE1","ipAddr":"172.20.0.5","status":"DOWN","overriddenStatus":"DOWN","port":{"$":8080,"@enabled":"true"},"securePort":{"$":0,"@enabled":"false"}," countryId":1,"dataCenterInfo":{"@class":"com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo","name":"MyOwn"},"leaseInfo":{"renewalIntervalInSecs":30,"durationInSecs":90,"reg"[truncated 1612 bytes]; line: 1, column: 18] at io.micronaut.http.client.netty.DefaultHttpClient$12.channelReadInstrumented(DefaultHttpClient.java:2206) at io.micronaut.http.client.netty.DefaultHttpClient$12.channelReadInstrumented(DefaultHttpClient.java:2076) at io.micronaut.http.client.netty.DefaultHttpClient$SimpleChannelInboundHandlerInstrumented.channelRead0(DefaultHttpClient.java:2780) at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:99) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.micronaut.http.netty.stream.HttpStreamsHandler.channelRead(HttpStreamsHandler.java:193) at io.micronaut.http.netty.stream.HttpStreamsClientHandler.channelRead(HttpStreamsClientHandler.java:183) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436) at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324) at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:296) at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166) at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:719) at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:655) at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:581) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.lang.Thread.run(Thread.java:829) at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:553) at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192) Caused by: io.micronaut.http.codec.CodecException: Error decoding stream for type [class io.micronaut.discovery.eureka.client.v2.AbstractEurekaClient$ApplicationInfos]: Cannot construct instance of `io.micronaut.discovery.eureka.client.v2.AbstractEurekaClient$ApplicationInfos` (no Creators, like default constructor, exist): cannot deserialize from Object value (no delegate- or property-based Creator) at [Source: (byte[])"{"applications":{"versions__delta":"1","apps__hashcode":"DOWN_1_UP_1_","application":[{"name":"MODULE1","instance":[{"instanceId":"module1:8080","hostName":"module1-001","app":"MODULE1","ipAddr":"172.20.0.5","status":"DOWN","overriddenStatus":"DOWN","port":{"$":8080,"@enabled":"true"},"securePort":{"$":0,"@enabled":"false"}," countryId":1,"dataCenterInfo":{"@class":"com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo","name":"MyOwn"},"leaseInfo":{"renewalIntervalInSecs":30,"durationInSecs":90,"reg"[truncated 1612 bytes]; line: 1, column: 18] at io.micronaut.jackson.codec.JacksonMediaTypeCodec.decode(JacksonMediaTypeCodec.java:209) at io.micronaut.http.client.netty.FullNettyClientHttpResponse.convertByteBuf(FullNettyClientHttpResponse.java:280) at io.micronaut.http.client.netty.FullNettyClientHttpResponse.lambda$getBody$1(FullNettyClientHttpResponse.java:218) at java.util.HashMap.computeIfAbsent(HashMap.java:1133) at io.micronaut.http.client.netty.FullNettyClientHttpResponse.getBody(FullNettyClientHttpResponse.java:192) at io.micronaut.http.client.netty.FullNettyClientHttpResponse.(FullNettyClientHttpResponse.java:111) at io.micronaut.http.client.netty.DefaultHttpClient$12.channelReadInstrumented(DefaultHttpClient.java:2136) ... 45 common frames omitted Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `io.micronaut.discovery.eureka.client.v2.AbstractEurekaClient$ApplicationInfos` (no Creators, like default constructor, exist): cannot deserialize from Object value (no delegate- or property-based Creator) at [Source: (byte[])"{"applications":{"versions__delta":"1","apps__hashcode":"DOWN_1_UP_1_","application":[{"name":"MODULE1","instance":[{"instanceId":"module1:8080","hostName":"module1-001","app":"MODULE1","ipAddr":"172.20.0.5","status":"DOWN","overriddenStatus":"DOWN","port":{"$":8080,"@enabled":"true"},"securePort":{"$":0,"@enabled":"false"}," countryId":1,"dataCenterInfo":{"@class":"com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo","name":"MyOwn"},"leaseInfo":{"renewalIntervalInSecs":30,"durationInSecs":90,"reg"[truncated 1612 bytes]; line: 1, column: 18] at com.fasterxml.jackson.databind.DeserializationContext.reportBadDefinition(DeserializationContext.java:1764) at com.fasterxml.jackson.databind.DatabindContext.reportBadDefinition(DatabindContext.java:400) at com.fasterxml.jackson.databind.DeserializationContext.handleMissingInstantiator(DeserializationContext.java:1209) at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1415) at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:362) at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:195) at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext._unwrapAndDeserialize(DefaultDeserializationContext.java:355) at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:319) at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4593) at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3609) at io.micronaut.jackson.codec.JacksonMediaTypeCodec.decode(JacksonMediaTypeCodec.java:206) ... 51 common frames omitted ```

Imho, Jackson fails because it uses an unsupported reflection access to deserialize io.micronaut.discovery.eureka.client.v2.AbstractEurekaClient.ApplicationInfo. Micronaut Documentation states that you have to annotate such classes with @Introspected to point out to the compiler to add additional configuration information.

Greets, Aaron

aaron-sr commented 3 years ago

I've tested a bit and this seems to a timing issue: If I restart the docker-native container, it registers fine to Eureka. Even if I restart Eureka, the docker-native container is able to register again. So maybe this error just occurs because GraalVM is so fast at startup, it outperforms the org.springframework.cloud.netflix.eureka.server.EnableEurekaServer instance.

Edit: Error still occurs. The health status seems to be delayed, so you have to wait until first occurrence.