Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-2109

GraalVM native image cannot be generated

XMLWordPrintable

      GraalVM has the capability of generating a SubstrateVM native image, which then doesn't require any JDK to run. This is very useful for minimizing app footprint and speeding up startup, among other things.

      When I attempt to generate a native image of an application which bundles RESTEasy, I get an exception coming from the fact that

      org.jboss.resteasy.plugins.providers.DocumentProvider

      doesn't have a no-arg constructor while still being available through Java's ServiceLoader SPI.

      The following is the output of the `native-image` tool, adjusted to remove the specifics of my application.

      $ ./native-image -jar myjar.jar
      Build on Server(pid: 16339, port: 46089)*
      [...:16339]    classlist:   4,843.88 ms
      [...:16339]        (cap):     941.14 ms
      [...:16339]        setup:   2,382.86 ms
      [...:16339]     analysis:  16,363.99 ms
      fatal error: java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: Class org.jboss.resteasy.plugins.providers.DocumentProvider cannot be instantiated reflectively . It does not have a nullary constructor.
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
      	at java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:593)
      	at java.util.concurrent.ForkJoinTask.get(ForkJoinTask.java:1005)
      	at com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:418)
      	at com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:278)
      	at com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:375)
      	at com.oracle.svm.hosted.server.NativeImageBuildServer.executeCompilation(NativeImageBuildServer.java:391)
      	at com.oracle.svm.hosted.server.NativeImageBuildServer.lambda$processCommand$8(NativeImageBuildServer.java:328)
      	at com.oracle.svm.hosted.server.NativeImageBuildServer.withJVMContext(NativeImageBuildServer.java:409)
      	at com.oracle.svm.hosted.server.NativeImageBuildServer.processCommand(NativeImageBuildServer.java:325)
      	at com.oracle.svm.hosted.server.NativeImageBuildServer.processRequest(NativeImageBuildServer.java:269)
      	at com.oracle.svm.hosted.server.NativeImageBuildServer.lambda$serve$7(NativeImageBuildServer.java:229)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at java.lang.Thread.run(Thread.java:748)
      Caused by: java.lang.IllegalArgumentException: Class org.jboss.resteasy.plugins.providers.DocumentProvider cannot be instantiated reflectively . It does not have a nullary constructor.
      	at org.graalvm.nativeimage.RuntimeReflection.registerForReflectiveInstantiation(RuntimeReflection.java:125)
      	at com.oracle.svm.hosted.ServiceLoaderFeature.handleType(ServiceLoaderFeature.java:208)
      	at com.oracle.svm.hosted.ServiceLoaderFeature.duringAnalysis(ServiceLoaderFeature.java:111)
      	at com.oracle.svm.hosted.NativeImageGenerator.lambda$doRun$7(NativeImageGenerator.java:708)
      	at com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:63)
      	at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:708)
      	at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:401)
      	at java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1386)
      	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
      	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
      	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
      	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
      Error: Processing image build request failed
      

              lpetrovi@redhat.com Lukáš Petrovický (Inactive)
              lpetrovi@redhat.com Lukáš Petrovický (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: