title: Build native image for micronaut application
body: <p>As the title indicates I'm trying to build a native image for a Kotlin based Micronaut application using Docker.</p>
  
  <p>I've added the following dependencies to my <code>build.gradle</code> file.</p>
  
  <pre><code>compileOnly 'org.graalvm.nativeimage:svm'
  annotationProcessor 'io.micronaut:micronaut-graal'
  </code></pre>
  
  <p>My Dockerfile looks as the following.</p>
  
  <pre><code>FROM oracle/graalvm-ce:20.1.0-java11 as graalvm
  RUN gu install native-image
  
  WORKDIR /src
  COPY . /src
  
  RUN ./gradlew assemble
  RUN native-image --no-server -cp build/libs/*-all.jar dk.fitfit.injurylog.Application
  
  FROM frolvlad/alpine-glibc
  RUN apk update &amp;&amp; apk add libstdc++
  COPY --from=graalvm /src/dk.fitfit.injurylog.application /app/app
  ENTRYPOINT ["/app/app"]
  </code></pre>
  
  <p>Everything things seems to be in order. The image boots and seems to accept connections but when I initiates a http request the following error occurs.</p>
  
  <pre><code>11:38:52.033 [nioEventLoopGroup-1-2] ERROR i.m.h.s.netty.RoutingInBoundHandler - Unexpected error occurred: Failed to inject value for field [jacksonModules] of class: dk.fitfit.injurylog.util.CustomObjectMapperFactory
  
  Message: Error setting field value: No field 'jacksonModules' found for type: io.micronaut.jackson.ObjectMapperFactory
  
  io.micronaut.context.exceptions.DependencyInjectionException: Failed to inject value for field [jacksonModules] of class: dk.fitfit.injurylog.util.CustomObjectMapperFactory
  
  Message: Error setting field value: No field 'jacksonModules' found for type: io.micronaut.jackson.ObjectMapperFactory
  
      at io.micronaut.context.AbstractBeanDefinition.injectBeanField(AbstractBeanDefinition.java:748)
      at dk.fitfit.injurylog.util.$CustomObjectMapperFactoryDefinition.injectBean(Unknown Source)
      at dk.fitfit.injurylog.util.$CustomObjectMapperFactoryDefinition.build(Unknown Source)
      at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1714)
      at io.micronaut.context.DefaultBeanContext.createAndRegisterSingletonInternal(DefaultBeanContext.java:2428)
      at io.micronaut.context.DefaultBeanContext.createAndRegisterSingleton(DefaultBeanContext.java:2414)
      at io.micronaut.context.DefaultBeanContext.getBeanForDefinition(DefaultBeanContext.java:2105)
      at io.micronaut.context.DefaultBeanContext.getBeanInternal(DefaultBeanContext.java:2079)
      at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:1078)
      at dk.fitfit.injurylog.util.$CustomObjectMapperFactory$ObjectMapper1Definition.build(Unknown Source)
      at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1714)
      at io.micronaut.context.DefaultBeanContext.createAndRegisterSingletonInternal(DefaultBeanContext.java:2428)
      at io.micronaut.context.DefaultBeanContext.createAndRegisterSingleton(DefaultBeanContext.java:2414)
      at io.micronaut.context.DefaultBeanContext.getBeanForDefinition(DefaultBeanContext.java:2105)
      at io.micronaut.context.DefaultBeanContext.getBeanInternal(DefaultBeanContext.java:2079)
      at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:616)
      at io.micronaut.context.UnresolvedProvider.get(UnresolvedProvider.java:58)
      at io.micronaut.jackson.codec.JacksonMediaTypeCodec.getObjectMapper(JacksonMediaTypeCodec.java:105)
      at io.micronaut.jackson.codec.JacksonMediaTypeCodec.encode(JacksonMediaTypeCodec.java:212)
      at io.micronaut.jackson.codec.JacksonMediaTypeCodec.encode(JacksonMediaTypeCodec.java:221)
      at io.micronaut.http.server.netty.RoutingInBoundHandler.encodeBodyAsByteBuf(RoutingInBoundHandler.java:1405)
      at io.micronaut.http.server.netty.RoutingInBoundHandler.encodeBodyWithCodec(RoutingInBoundHandler.java:1351)
      at io.micronaut.http.server.netty.RoutingInBoundHandler.lambda$subscribeToResponsePublisher$12(RoutingInBoundHandler.java:1272)
      at io.reactivex.internal.operators.flowable.FlowableMap$MapSubscriber.onNext(FlowableMap.java:63)
      at io.micronaut.reactive.rxjava2.RxInstrumentedSubscriber.onNext(RxInstrumentedSubscriber.java:72)
      at io.reactivex.internal.operators.flowable.FlowableSubscribeOn$SubscribeOnSubscriber.onNext(FlowableSubscribeOn.java:97)
      at io.micronaut.reactive.rxjava2.RxInstrumentedSubscriber.onNext(RxInstrumentedSubscriber.java:72)
      at io.micronaut.http.context.ServerRequestTracingPublisher$1.lambda$onNext$1(ServerRequestTracingPublisher.java:60)
      at io.micronaut.http.context.ServerRequestContext.with(ServerRequestContext.java:68)
      at io.micronaut.http.context.ServerRequestTracingPublisher$1.onNext(ServerRequestTracingPublisher.java:60)
      at io.micronaut.http.context.ServerRequestTracingPublisher$1.onNext(ServerRequestTracingPublisher.java:52)
      at io.reactivex.internal.util.HalfSerializer.onNext(HalfSerializer.java:45)
      at io.reactivex.internal.subscribers.StrictSubscriber.onNext(StrictSubscriber.java:97)
      at io.micronaut.reactive.rxjava2.RxInstrumentedSubscriber.onNext(RxInstrumentedSubscriber.java:72)
      at io.reactivex.internal.operators.flowable.FlowableSwitchIfEmpty$SwitchIfEmptySubscriber.onNext(FlowableSwitchIfEmpty.java:59)
      at io.micronaut.reactive.rxjava2.RxInstrumentedSubscriber.onNext(RxInstrumentedSubscriber.java:67)
      at io.reactivex.internal.subscriptions.ScalarSubscription.request(ScalarSubscription.java:55)
      at io.reactivex.internal.subscriptions.SubscriptionArbiter.setSubscription(SubscriptionArbiter.java:99)
      at io.reactivex.internal.operators.flowable.FlowableSwitchIfEmpty$SwitchIfEmptySubscriber.onSubscribe(FlowableSwitchIfEmpty.java:51)
      at io.micronaut.reactive.rxjava2.RxInstrumentedSubscriber.onSubscribe(RxInstrumentedSubscriber.java:56)
      at io.reactivex.internal.operators.flowable.FlowableJust.subscribeActual(FlowableJust.java:34)
      at io.reactivex.Flowable.subscribe(Flowable.java:14935)
      at io.reactivex.Flowable.subscribe(Flowable.java:14882)
      at io.micronaut.reactive.rxjava2.RxInstrumentedFlowable.subscribeActual(RxInstrumentedFlowable.java:58)
      at io.reactivex.Flowable.subscribe(Flowable.java:14935)
      at io.reactivex.Flowable.subscribe(Flowable.java:14882)
      at io.reactivex.internal.operators.flowable.FlowableDefer.subscribeActual(FlowableDefer.java:42)
      at io.reactivex.Flowable.subscribe(Flowable.java:14935)
      at io.reactivex.Flowable.subscribe(Flowable.java:14882)
      at io.micronaut.reactive.rxjava2.RxInstrumentedFlowable.subscribeActual(RxInstrumentedFlowable.java:58)
      at io.reactivex.Flowable.subscribe(Flowable.java:14935)
      at io.reactivex.internal.operators.flowable.FlowableSwitchIfEmpty.subscribeActual(FlowableSwitchIfEmpty.java:32)
      at io.reactivex.Flowable.subscribe(Flowable.java:14935)
      at io.reactivex.Flowable.subscribe(Flowable.java:14882)
      at io.micronaut.reactive.rxjava2.RxInstrumentedFlowable.subscribeActual(RxInstrumentedFlowable.java:58)
      at io.reactivex.Flowable.subscribe(Flowable.java:14935)
      at io.reactivex.Flowable.subscribe(Flowable.java:14885)
      at io.micronaut.http.context.ServerRequestTracingPublisher.lambda$subscribe$0(ServerRequestTracingPublisher.java:52)
      at io.micronaut.http.context.ServerRequestContext.with(ServerRequestContext.java:68)
      at io.micronaut.http.context.ServerRequestTracingPublisher.subscribe(ServerRequestTracingPublisher.java:52)
      at io.reactivex.internal.operators.flowable.FlowableFromPublisher.subscribeActual(FlowableFromPublisher.java:29)
      at io.reactivex.Flowable.subscribe(Flowable.java:14935)
      at io.reactivex.Flowable.subscribe(Flowable.java:14882)
      at io.micronaut.reactive.rxjava2.RxInstrumentedFlowable.subscribeActual(RxInstrumentedFlowable.java:58)
      at io.reactivex.Flowable.subscribe(Flowable.java:14935)
      at io.reactivex.Flowable.subscribe(Flowable.java:14882)
      at io.reactivex.internal.operators.flowable.FlowableSubscribeOn$SubscribeOnSubscriber.run(FlowableSubscribeOn.java:82)
      at io.reactivex.internal.schedulers.ExecutorScheduler$ExecutorWorker$BooleanRunnable.run(ExecutorScheduler.java:288)
      at io.reactivex.internal.schedulers.ExecutorScheduler$ExecutorWorker.run(ExecutorScheduler.java:253)
      at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
      at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
      at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
      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:834)
      at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:517)
      at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:193)
  Caused by: java.lang.NoSuchFieldError: No field 'jacksonModules' found for type: io.micronaut.jackson.ObjectMapperFactory
      at io.micronaut.core.reflect.ReflectionUtils.lambda$getRequiredField$2(ReflectionUtils.java:301)
      at java.util.Optional.orElseThrow(Optional.java:408)
      at io.micronaut.core.reflect.ReflectionUtils.getRequiredField(ReflectionUtils.java:301)
      at io.micronaut.context.DefaultFieldInjectionPoint.getField(DefaultFieldInjectionPoint.java:117)
      at io.micronaut.context.DefaultFieldInjectionPoint.set(DefaultFieldInjectionPoint.java:127)
      at io.micronaut.context.AbstractBeanDefinition.injectBeanField(AbstractBeanDefinition.java:742)
      ... 77 common frames omitted
  </code></pre>
  
  <p>Any clue about how to avoid the above error?</p>