Micronaut-core: eureka service discovery doesn't work with native-image

Created on 18 Oct 2019  路  8Comments  路  Source: micronaut-projects/micronaut-core

Thanks for reporting an issue for Micronaut, please review the task list below before submitting the
issue. Your issue report will be closed if the issue is incomplete and the below tasks not completed.

NOTE: If you are unsure about something and the issue is more of a question a better place to ask questions is on Stack Overflow (http://stackoverflow.com/tags/micronaut) or Gitter (https://gitter.im/micronautfw/). DO NOT use the issue tracker to ask questions.

Task List

  • [ ] Steps to reproduce provided
  • [ ] Stacktrace (if present) provided
  • [ ] Example that reproduces the problem uploaded to Github
  • [ ] Full description of the issue provided (see below)

Steps to Reproduce

It's necessary to have a eureka server started.

  1. Use eureka service discovery feature.
  2. Compile with micronaut 1.2.2 and graalvm-ce-19.2.1/native-image into docker image.
    2.1. mvn clean package
    2.2. docker build . -t imagedocker:version
  3. Start imagen docker
    3.1. docker run -p 8080:8080 -e EUREKA_SERVER=URL_EUREKA_SERVER --HOSTNAME=NAMEOFINSTANCE imagedocker:version

Expected Behaviour

Start the service and registered to eureka server

Actual Behaviour

The register to eureka server fails

Environment Information

  • Operating System: docker image oracle/graalvm-ce:19.2.1
  • Micronaut Version: 1.2.2
  • JDK Version: graalvm-ce:19.2.1

Example Application

When I compile without native-image and use java-jar command the application works, but when I compile with native-image from graalvm-ce-19.2.1 the application doesn't work correctly.
08:27:43.837 [main] INFO io.micronaut.runtime.Micronaut - Startup completed in 46ms. Server Running: http://mn-first-rest-3:8080 08:27:48.862 [nioEventLoopGroup-2-3] INFO i.m.d.registration.AutoRegistration - Instance [mn-first-rest-3] no longer registered with Eureka. Attempting re-registration. 08:27:48.891 [nioEventLoopGroup-2-4] ERROR i.m.d.registration.AutoRegistration - Error reporting state to Eureka: io.micronaut.http.client.exceptions.HttpClientResponseException: at io.micronaut.http.client.DefaultHttpClient$10.channelRead0(DefaultHttpClient.java:1816) at io.micronaut.http.client.DefaultHttpClient$10.channelRead0(DefaultHttpClient.java:1756) at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) at io.micronaut.http.netty.stream.HttpStreamsHandler.channelRead(HttpStreamsHandler.java:185) at io.micronaut.http.netty.stream.HttpStreamsClientHandler.channelRead(HttpStreamsClientHandler.java:180) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:438)

graal awaiting validation bug

Most helpful comment

@graemerocher sure, added to my list.

All 8 comments

is there any piece of news about this issue?

Not yet, will take a look soon...

Is there any update on this?
Any workarounds for registering to Eureka from native compiled micronaut application?

Thanks

I would love to see this fixed as well, I've been trying to fix it but I don't think I'm on the right path so far.

@ilopmar could you take a look at this one?

@graemerocher sure, added to my list.

In the meantime the following code snippet will help you to register to Eureka (it compiles to native code) .

https://github.com/sandhya-grl/micronaut_eureka_client/blob/master/EurekaRegistration.java

I've submitted a PR with the fix: https://github.com/micronaut-projects/micronaut-core/pull/3379

@ustari28 @prakis @anthonyrichir I've also created a test application that I'll add to our test suite once the PR is merged: https://github.com/micronaut-graal-tests/micronaut-service-discovery-eureka/ (look at master or 1.3.x depending the Micronaut version you are using)

Was this page helpful?
0 / 5 - 0 ratings