You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I understand if this is not a priority right now but ever since I first heard of Micronaut and how it consumes less resources (especially memory) and allow faster startup time than vanilla Spring Boot I'd wanted to try to run Micronaut with Graal. That would be extremely cool and really take the points on memory consumption, startup time etc to the next level (and it would probably make for a really good selling point).
Anyway I just made an initial attempt to do this by using this Dockerfile (inspiraton taken from this excellent blog):
FROM findepi/graalvm:native as builder
# build our applicationWORKDIR /builder
ADD ./target/micronaut-example*.jar /builder/server.jar
RUN native-image \
--static \
-H:IncludeResources="/resources/.*" \
-jar server.jar
RUN rm server.jar
###### The actual image to run#####FROM alpine:3.7
RUN apk --no-cache add ca-certificates
WORKDIR /app
EXPOSE 8080
COPY --from=builder /builder/server .
CMD ./server
Steps to Reproduce
docker build -t micronaut-example .
Expected Behaviour
It should build 😃
Actual Behaviour
Sending build context to Docker daemon 15.21MB
Step 1/11 : FROM findepi/graalvm:native as builder
native: Pulling from findepi/graalvm
b66481ccd4ca: Pull complete
dbeddf2084b2: Pull complete
ff8809b646d1: Pull complete
Digest: sha256:f7572bd2558629f5cdd264766b4b86b78ae99ebf9ef198717148974cac0c8592
Status: Downloaded newer image for findepi/graalvm:native
---> 7b2a0e9403e6
Step 2/11 : WORKDIR /builder
Removing intermediate container 4fad8aa430df
---> 1930eeed0f83
Step 3/11 : ADD ./target/micronaut-example*.jar /builder/server.jar
---> cce913be99be
Step 4/11 : RUN native-image --static -H:IncludeResources="/resources/.*" -jar server.jar
---> Running in 366980dcec81
Build on Server(pid: 11, port: 39789)*
classlist: 6,223.72 ms
(cap): 1,094.06 ms
setup: 2,375.03 ms
RecomputeFieldValue.ArrayIndexScale automatic substitution failed. The automatic substitution registration was attempted because a call to sun.misc.Unsafe.arrayIndexScale(Class) was detected in the static initializer of io.micronaut.caffeine.cache.UnsafeRefArrayAccess. Add a RecomputeFieldValue.ArrayIndexScale manual substitution for io.micronaut.caffeine.cache.UnsafeRefArrayAccess.
analysis: 17,159.11 ms
error: unsupported features in 6 methods
Detailed message:
Error: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Unsupported field java.lang.reflect.Proxy.proxyClassCache is reachable
To diagnose the issue, you can add the option -H:+ReportUnsupportedElementsAtRuntime. The unsupported element is then reported at run time when it is accessed the first time.
Trace:
at parsing java.lang.reflect.Proxy.getProxyClass0(Proxy.java:419)
Call path from entry point to java.lang.reflect.Proxy.getProxyClass0(ClassLoader, Class[]):
at java.lang.reflect.Proxy.getProxyClass0(Proxy.java:412)
at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:719)
at sun.reflect.annotation.AnnotationParser$1.run(AnnotationParser.java:305)
at sun.reflect.annotation.AnnotationParser$1.run(AnnotationParser.java:303)
at com.oracle.svm.core.jdk.Target_java_security_AccessController.doPrivileged(SecuritySubstitutions.java:70)
at java.util.SplittableRandom.initialSeed(SplittableRandom.java:228)
at com.oracle.svm.core.jdk.Target_java_util_SplittableRandom.<init>(JavaUtilSubstitutions.java:233)
at com.oracle.svm.core.jdk.IdentityHashCodeSupport.generateHashCode(IdentityHashCodeSupport.java:43)
at com.oracle.svm.core.jdk.Target_java_lang_System.identityHashCode(JavaLangSubstitutions.java:332)
at java.util.IdentityHashMap.hash(IdentityHashMap.java:295)
at java.util.IdentityHashMap.containsKey(IdentityHashMap.java:353)
at com.oracle.svm.core.jdk.Target_java_lang_ApplicationShutdownHooks.add(JavaLangSubstitutions.java:603)
at java.lang.Runtime.addShutdownHook(Runtime.java:211)
at com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:170)
at com.oracle.svm.core.code.CEntryPointCallStubs.com_002eoracle_002esvm_002ecore_002eJavaMainWrapper_002erun_0028int_002corg_002egraalvm_002enativeimage_002ec_002etype_002eCCharPointerPointer_0029(generated:0)
Error: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Unsupported field java.lang.reflect.Proxy.proxyClassCache is reachable
To diagnose the issue, you can add the option -H:+ReportUnsupportedElementsAtRuntime. The unsupported element is then reported at run time when it is accessed the first time.
Trace:
at parsing java.lang.reflect.Proxy.isProxyClass(Proxy.java:791)
Call path from entry point to java.lang.reflect.Proxy.isProxyClass(Class):
at java.lang.reflect.Proxy.isProxyClass(Proxy.java:791)
at sun.reflect.misc.ReflectUtil.isNonPublicProxyClass(ReflectUtil.java:289)
at java.lang.reflect.Proxy.checkNewProxyPermission(Proxy.java:757)
at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:726)
at sun.reflect.annotation.AnnotationParser$1.run(AnnotationParser.java:305)
at sun.reflect.annotation.AnnotationParser$1.run(AnnotationParser.java:303)
at com.oracle.svm.core.jdk.Target_java_security_AccessController.doPrivileged(SecuritySubstitutions.java:70)
at java.util.SplittableRandom.initialSeed(SplittableRandom.java:228)
at com.oracle.svm.core.jdk.Target_java_util_SplittableRandom.<init>(JavaUtilSubstitutions.java:233)
at com.oracle.svm.core.jdk.IdentityHashCodeSupport.generateHashCode(IdentityHashCodeSupport.java:43)
at com.oracle.svm.core.jdk.Target_java_lang_System.identityHashCode(JavaLangSubstitutions.java:332)
at java.util.IdentityHashMap.hash(IdentityHashMap.java:295)
at java.util.IdentityHashMap.containsKey(IdentityHashMap.java:353)
at com.oracle.svm.core.jdk.Target_java_lang_ApplicationShutdownHooks.add(JavaLangSubstitutions.java:603)
at java.lang.Runtime.addShutdownHook(Runtime.java:211)
at com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:170)
at com.oracle.svm.core.code.CEntryPointCallStubs.com_002eoracle_002esvm_002ecore_002eJavaMainWrapper_002erun_0028int_002corg_002egraalvm_002enativeimage_002ec_002etype_002eCCharPointerPointer_0029(generated:0)
Error: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Unsupported method java.lang.Class.getConstantPool() is reachable: The declaring class of this element has been substituted, but this element is not present in the substitution class
To diagnose the issue, you can add the option -H:+ReportUnsupportedElementsAtRuntime. The unsupported element is then reported at run time when it is accessed the first time.
Trace:
at parsing java.lang.System$2.getConstantPool(System.java:1227)
Call path from entry point to java.lang.System$2.getConstantPool(Class):
at java.lang.System$2.getConstantPool(System.java:1227)
at sun.reflect.annotation.TypeAnnotationParser.parseAllTypeAnnotations(TypeAnnotationParser.java:323)
at sun.reflect.annotation.TypeAnnotationParser.parseTypeVariableAnnotations(TypeAnnotationParser.java:218)
at sun.reflect.generics.reflectiveObjects.TypeVariableImpl.getAnnotations(TypeVariableImpl.java:233)
at io.micronaut.core.annotation.AnnotationSource.lambda$getAnnotations$1(AnnotationSource.java:152)
at io.micronaut.core.annotation.AnnotationSource$$Lambda$489/1704364704.apply(Unknown Source)
at io.micronaut.runtime.Micronaut.handleStartupException(Micronaut.java:234)
at io.micronaut.runtime.Micronaut.start(Micronaut.java:89)
at micronaut.example.Application.main(Application.kt:12)
at com.oracle.svm.reflect.proxies.Proxy_1_Application_main.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:173)
at com.oracle.svm.core.code.CEntryPointCallStubs.com_002eoracle_002esvm_002ecore_002eJavaMainWrapper_002erun_0028int_002corg_002egraalvm_002enativeimage_002ec_002etype_002eCCharPointerPointer_0029(generated:0)
Error: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Unsupported method java.lang.Class.getExecutableTypeAnnotationBytes(Executable) is reachable: The declaring class of this element has been substituted, but this element is not present in the substitution class
To diagnose the issue, you can add the option -H:+ReportUnsupportedElementsAtRuntime. The unsupported element is then reported at run time when it is accessed the first time.
Trace:
at parsing java.lang.System$2.getRawExecutableTypeAnnotations(System.java:1245)
Call path from entry point to java.lang.System$2.getRawExecutableTypeAnnotations(Executable):
at java.lang.System$2.getRawExecutableTypeAnnotations(System.java:1245)
at sun.reflect.annotation.TypeAnnotationParser.parseAllTypeAnnotations(TypeAnnotationParser.java:318)
at sun.reflect.annotation.TypeAnnotationParser.parseTypeVariableAnnotations(TypeAnnotationParser.java:218)
at sun.reflect.generics.reflectiveObjects.TypeVariableImpl.getAnnotations(TypeVariableImpl.java:233)
at io.micronaut.core.annotation.AnnotationSource.lambda$getAnnotations$1(AnnotationSource.java:152)
at io.micronaut.core.annotation.AnnotationSource$$Lambda$489/1704364704.apply(Unknown Source)
at io.micronaut.runtime.Micronaut.handleStartupException(Micronaut.java:234)
at io.micronaut.runtime.Micronaut.start(Micronaut.java:89)
at micronaut.example.Application.main(Application.kt:12)
at com.oracle.svm.reflect.proxies.Proxy_1_Application_main.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:173)
at com.oracle.svm.core.code.CEntryPointCallStubs.com_002eoracle_002esvm_002ecore_002eJavaMainWrapper_002erun_0028int_002corg_002egraalvm_002enativeimage_002ec_002etype_002eCCharPointerPointer_0029(generated:0)
Error: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Unsupported method java.lang.Class.getRawTypeAnnotations() is reachable: The declaring class of this element has been substituted, but this element is not present in the substitution class
To diagnose the issue, you can add the option -H:+ReportUnsupportedElementsAtRuntime. The unsupported element is then reported at run time when it is accessed the first time.
Trace:
at parsing java.lang.System$2.getRawClassTypeAnnotations(System.java:1242)
Call path from entry point to java.lang.System$2.getRawClassTypeAnnotations(Class):
at java.lang.System$2.getRawClassTypeAnnotations(System.java:1242)
at sun.reflect.annotation.TypeAnnotationParser.parseAllTypeAnnotations(TypeAnnotationParser.java:315)
at sun.reflect.annotation.TypeAnnotationParser.parseTypeVariableAnnotations(TypeAnnotationParser.java:218)
at sun.reflect.generics.reflectiveObjects.TypeVariableImpl.getAnnotations(TypeVariableImpl.java:233)
at io.micronaut.core.annotation.AnnotationSource.lambda$getAnnotations$1(AnnotationSource.java:152)
at io.micronaut.core.annotation.AnnotationSource$$Lambda$489/1704364704.apply(Unknown Source)
at io.micronaut.runtime.Micronaut.handleStartupException(Micronaut.java:234)
at io.micronaut.runtime.Micronaut.start(Micronaut.java:89)
at micronaut.example.Application.main(Application.kt:12)
at com.oracle.svm.reflect.proxies.Proxy_1_Application_main.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:173)
at com.oracle.svm.core.code.CEntryPointCallStubs.com_002eoracle_002esvm_002ecore_002eJavaMainWrapper_002erun_0028int_002corg_002egraalvm_002enativeimage_002ec_002etype_002eCCharPointerPointer_0029(generated:0)
Error: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Unsupported method java.security.ProtectionDomain.getCodeSource() is reachable: The declaring class of this element has been substituted, but this element is not present in the substitution class
To diagnose the issue, you can add the option -H:+ReportUnsupportedElementsAtRuntime. The unsupported element is then reported at run time when it is accessed the first time.
Trace:
at parsing ch.qos.logback.classic.spi.PackagingDataCalculator.getCodeLocation(PackagingDataCalculator.java:164)
Call path from entry point to ch.qos.logback.classic.spi.PackagingDataCalculator.getCodeLocation(Class):
at ch.qos.logback.classic.spi.PackagingDataCalculator.getCodeLocation(PackagingDataCalculator.java:162)
at ch.qos.logback.classic.spi.PackagingDataCalculator.calculateByExactType(PackagingDataCalculator.java:123)
at ch.qos.logback.classic.spi.PackagingDataCalculator.populateFrames(PackagingDataCalculator.java:96)
at ch.qos.logback.classic.spi.PackagingDataCalculator.calculate(PackagingDataCalculator.java:58)
at ch.qos.logback.classic.spi.ThrowableProxy.calculatePackagingData(ThrowableProxy.java:142)
at ch.qos.logback.classic.spi.LoggingEvent.<init>(LoggingEvent.java:122)
at ch.qos.logback.classic.Logger.buildLoggingEventAndAppend(Logger.java:419)
at ch.qos.logback.classic.Logger.filterAndLog_0_Or3Plus(Logger.java:383)
at ch.qos.logback.classic.Logger.info(Logger.java:579)
at io.micronaut.runtime.Micronaut.start(Micronaut.java:85)
at micronaut.example.Application.main(Application.kt:12)
at com.oracle.svm.reflect.proxies.Proxy_1_Application_main.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:173)
at com.oracle.svm.core.code.CEntryPointCallStubs.com_002eoracle_002esvm_002ecore_002eJavaMainWrapper_002erun_0028int_002corg_002egraalvm_002enativeimage_002ec_002etype_002eCCharPointerPointer_0029(generated:0)
Error: Processing image build request failed
The command '/bin/sh -c native-image --static -H:IncludeResources="/resources/.*" -jar server.jar' returned a non-zero code: 1
Environment Information
Operating System: MacOSX
Micronaut Version: 1.0.0.M2
JDK Version: 1.8.0_144
Comments
I cannot use e.g. sun.misc.Unsafe in Graal and it seems like you cannot use java.security.ProtectionDomain either.
Again I do perfectly understand this might never happen, I mainly wanted you to know that I've given it a go and hear your thoughts. Feel free to close it if it's deemed to be out of scope.
The text was updated successfully, but these errors were encountered:
I understand if this is not a priority right now but ever since I first heard of Micronaut and how it consumes less resources (especially memory) and allow faster startup time than vanilla Spring Boot I'd wanted to try to run Micronaut with Graal. That would be extremely cool and really take the points on memory consumption, startup time etc to the next level (and it would probably make for a really good selling point).
Anyway I just made an initial attempt to do this by using this
Dockerfile
(inspiraton taken from this excellent blog):Steps to Reproduce
docker build -t micronaut-example .
Expected Behaviour
It should build 😃
Actual Behaviour
Environment Information
Comments
I cannot use e.g.
sun.misc.Unsafe
in Graal and it seems like you cannot usejava.security.ProtectionDomain
either.Again I do perfectly understand this might never happen, I mainly wanted you to know that I've given it a go and hear your thoughts. Feel free to close it if it's deemed to be out of scope.
The text was updated successfully, but these errors were encountered: