Graal: 1.0.0.RC10 cannot run Micronaut 1.0.2

Created on 8 Jan 2019  路  7Comments  路  Source: oracle/graal

Have been trying to get a graal native image to build and run with a hello world Micronaut 1.0.2 application. Using these options as suggested from other issues and my own experiment I get it to build, but when it runs it exits with

INFO  io.micronaut.runtime.Micronaut - No embedded container found. Running as CLI application

If I run the shadow all jar with normal JDK it prints out the normal embedded server message. Doing some research this seems to indicate that the netty library is missing but it is part of the jar file. Is it being optimized away somehow?

Here are my compile options:

native-image -jar build/libs/app-all.jar --allow-incomplete-classpath \
    --static --report-unsupported-elements-at-runtime \
    --enable-http --enable-https --enable-all-security-services -da \
    -H:-UseServiceLoaderFeature -H:Name=app -H:Class=com.example.app.Application
native-image

Most helpful comment

While JVMCI in JDK 11 is API compatible with the version in Labs JDK 8, it is not bug compatible. We continue to fix JVMCI bugs in Labs JDK 8 but the version of JVMCI in JDK 11 is fixed to whatever it was when JDK 11 was frozen. For SVM/native-image development in particular, I would recommend sticking with Labs JDK 8. You could try later JDKs (including early access versions) which have more recent JVMCI bug fixes but still your mileage may vary.

All 7 comments

In addition to the generated app from the micronaut cli I followed the steps on http://guides.micronaut.io/micronaut-creating-first-graal-app/guide/index.html to add Graal support. Here is the Dockerfile I use to build

FROM openjdk:11.0.1-jdk-slim as build
#gcc needed to compile Graal image as well as zlib
RUN apt-get update && apt-get install curl gcc libpng-dev zlib1g-dev -y
RUN mkdir app
WORKDIR app
RUN curl -L -o graalvm.tar.gz "https://github.com/oracle/graal/releases/download/vm-1.0.0-rc10/graalvm-ce-1.0.0-rc10-linux-amd64.tar.gz"
RUN mkdir graal && tar -xzf graalvm.tar.gz --directory graal && rm graalvm.tar.gz
COPY . .
RUN ./gradlew build && mv build/libs/app-*-all.jar build/libs/app-all.jar

# Build native image using graalvm

RUN graal/*/bin/native-image -jar build/libs/app-all.jar --allow-incomplete-classpath \
    --static --report-unsupported-elements-at-runtime \
    --enable-http --enable-https --enable-all-security-services -da \
    -H:-UseServiceLoaderFeature -H:Name=app -H:Class=com.example.app.Application

# Graal native image version
FROM alpine:3.8
COPY --from=build /app/app .
ENTRYPOINT [ "/app/app" ]

Might be because I am building with JDK11 even though I set source and target compatibility to 1.8. When I get on a better internet connection I'll try a JDK8 base image.

@justinjohn83 we made some progress recently with Micronaut. You should try building with Micronaut 1.0.3 and GraalVM RC11 which should be released next week (or build from master).

@cstancu we are currently hitting https://github.com/oracle/graal/issues/900

That is with master.. could you take a look?

@justinjohn83 #900 is fixed: the problem was using an older version of JVMCI, labsjdk1.8.0_192-jvmci-0.50. Everything works as expected with labsjdk1.8.0_192-jvmci-0.53. Can you please confirm that your example also works with Micronaut 1.0.3, latest GraalVM master, i.e., GraalVM Version 1.0.0-rc12-dev, and labsjdk1.8.0_192-jvmci-0.53, and close this issue? Thanks!

Can it only be built with the labsjdk1.8.0_192-jvmci-0.53 and not using OpenJDK11? The README indicates JDK11 can be used instead since JVMCI has been available since JEP 243 - https://github.com/oracle/graal/blob/master/compiler/README.md. I was able to build the substrateVM with JDK11.

But if I run it against OpenJDK 11 when it attempts to build the micronaut 1.0.3 app using same arguments as before I get

cd graal/substratevm && mx native-image -jar --allow-incomplete-classpath \
    --static --report-unsupported-elements-at-runtime \
    --enable-http --enable-https --enable-all-security-services -da \
    -H:-UseServiceLoaderFeature -H:Name=app -H:Class=com.example.app.Application
 analysis:  13,723.81 ms
error: Error encountered while parsing com.oracle.svm.reflect.$Proxy167_constructor_6f495d66c7751080c4841e8214c396251a5e04dc.newInstance(java.lang.Object[]) 
Parsing context:
    parsing [email protected]/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
    parsing [email protected]/sun.net.www.protocol.http.Negotiator.getNegotiator(Negotiator.java:65)
    parsing [email protected]/sun.net.www.protocol.http.NegotiateAuthentication.firstToken(NegotiateAuthentication.java:234)
    parsing [email protected]/sun.net.www.protocol.http.NegotiateAuthentication.setHeaders(NegotiateAuthentication.java:209)
    parsing [email protected]/sun.net.www.protocol.http.HttpURLConnection.getHttpProxyAuthentication(HttpURLConnection.java:2398)
    parsing [email protected]/sun.net.www.protocol.http.HttpURLConnection.resetProxyAuthentication(HttpURLConnection.java:2018)
    parsing [email protected]/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1669)
    parsing [email protected]/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1509)
    parsing [email protected]/java.net.URL.openStream(URL.java:1117)
    parsing io.micronaut.core.io.service.SoftServiceLoader$ServiceLoaderIterator.hasNext(SoftServiceLoader.java:203)
    parsing io.micronaut.core.io.service.SoftServiceLoader$ServiceLoaderIterator.next(SoftServiceLoader.java:227)
    parsing io.micronaut.core.io.service.SoftServiceLoader$ServiceLoaderIterator.next(SoftServiceLoader.java:182)
    parsing io.micronaut.core.io.service.SoftServiceLoader$1.next(SoftServiceLoader.java:159)
    parsing io.micronaut.core.io.service.SoftServiceLoader$1.next(SoftServiceLoader.java:137)
    parsing io.micronaut.context.env.DefaultEnvironment.evaluatePropertySourceLoaders(DefaultEnvironment.java:473)
    parsing io.micronaut.context.env.DefaultEnvironment.getPropertySourceLoaders(DefaultEnvironment.java:461)
    parsing io.micronaut.context.env.DefaultEnvironment.readPropertySourceListFromFiles(DefaultEnvironment.java:387)
    parsing io.micronaut.context.env.DefaultEnvironment.readPropertySources(DefaultEnvironment.java:357)
    parsing io.micronaut.context.env.DefaultEnvironment.start(DefaultEnvironment.java:246)
    parsing io.micronaut.context.env.DefaultEnvironment.start(DefaultEnvironment.java:66)
    parsing io.micronaut.context.DefaultApplicationContext.startEnvironment(DefaultApplicationContext.java:182)
    parsing io.micronaut.context.DefaultApplicationContext.start(DefaultApplicationContext.java:140)
    parsing io.micronaut.runtime.Micronaut.start(Micronaut.java:67)
    parsing io.micronaut.runtime.Micronaut.run(Micronaut.java:274)
    parsing io.micronaut.runtime.Micronaut.run(Micronaut.java:260)
    parsing com.example.app.Application.main(Application.java:8)
    parsing app//com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:164)
    parsing com.oracle.svm.core.code.IsolateEnterStub.JavaMainWrapper_run_5087f5482cc9a6abc971913ece43acb471d2631b(generated:0)
Original error: java.lang.NullPointerException
    at com.oracle.svm.hosted.code.CFunctionSubstitutionProcessor.lookup(CFunctionSubstitutionProcessor.java:44)
    at com.oracle.graal.pointsto.infrastructure.SubstitutionProcessor$ChainedSubstitutionProcessor.lookup(SubstitutionProcessor.java:128)
    at com.oracle.graal.pointsto.infrastructure.SubstitutionProcessor$ChainedSubstitutionProcessor.lookup(SubstitutionProcessor.java:128)
    at com.oracle.graal.pointsto.infrastructure.SubstitutionProcessor$ChainedSubstitutionProcessor.lookup(SubstitutionProcessor.java:128)
    at com.oracle.graal.pointsto.meta.AnalysisUniverse.lookupAllowUnresolved(AnalysisUniverse.java:380)
    at com.oracle.graal.pointsto.meta.AnalysisUniverse.lookup(AnalysisUniverse.java:360)
    at com.oracle.graal.pointsto.meta.AnalysisUniverse.lookup(AnalysisUniverse.java:69)
    at com.oracle.graal.pointsto.infrastructure.UniverseMetaAccess.lookupJavaMethod(UniverseMetaAccess.java:99)
    at com.oracle.graal.pointsto.meta.AnalysisMetaAccess.lookupJavaMethod(AnalysisMetaAccess.java:67)
    at com.oracle.graal.pointsto.meta.AnalysisMetaAccess.lookupJavaMethod(AnalysisMetaAccess.java:40)
    at com.oracle.svm.reflect.hosted.ReflectionSubstitutionType$ReflectiveNewInstanceMethod.buildGraph(ReflectionSubstitutionType.java:587)
    at com.oracle.graal.pointsto.meta.AnalysisMethod.buildGraph(AnalysisMethod.java:306)
    at com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.parse(MethodTypeFlowBuilder.java:176)
    at com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.apply(MethodTypeFlowBuilder.java:323)
    at com.oracle.graal.pointsto.flow.MethodTypeFlow.doParse(MethodTypeFlow.java:310)
    at com.oracle.graal.pointsto.flow.MethodTypeFlow.ensureParsed(MethodTypeFlow.java:300)
    at com.oracle.graal.pointsto.flow.MethodTypeFlow.addContext(MethodTypeFlow.java:107)
    at com.oracle.graal.pointsto.DefaultAnalysisPolicy$DefaultVirtualInvokeTypeFlow.onObservedUpdate(DefaultAnalysisPolicy.java:186)
    at com.oracle.graal.pointsto.flow.TypeFlow.notifyObservers(TypeFlow.java:347)
    at com.oracle.graal.pointsto.flow.TypeFlow.update(TypeFlow.java:389)
    at com.oracle.graal.pointsto.BigBang$2.run(BigBang.java:508)
    at com.oracle.graal.pointsto.util.CompletionExecutor.lambda$execute$0(CompletionExecutor.java:174)
    at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1426)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
    at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
    at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
    at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)

Error: Image building with exit status 1

Would rather not use the labs JDK if I don't need to but will try again tomorrow with it if that's the only supported way currently.

While JVMCI in JDK 11 is API compatible with the version in Labs JDK 8, it is not bug compatible. We continue to fix JVMCI bugs in Labs JDK 8 but the version of JVMCI in JDK 11 is fixed to whatever it was when JDK 11 was frozen. For SVM/native-image development in particular, I would recommend sticking with Labs JDK 8. You could try later JDKs (including early access versions) which have more recent JVMCI bug fixes but still your mileage may vary.

Was this page helpful?
0 / 5 - 0 ratings