When trying to build a native image from a new uber jar, I get the below message.
I have generated the needed config (in META-INF) file needed using the tracing agent and also manually added an entry.
Command:
OPTIONS="${2:-} --no-fallback --allow-incomplete-classpath --enable-all-security-services
--enable-http --enable-https --enable-url-protocols"
native-image ${OPTIONS} -jar ${JARFILE} ${IMAGE_NAME}
Config (META-INF/native-image) snippet related to the error:
{
"name":"org.aeonbits.owner.crypto.IdentityDecryptor",
"methods":[{"name":"<init>","parameterTypes":[] }],
"allPublicMethods":true
},
I have added the above to the reflect-config.json file but has no effect.
Output:
16:57:13.830 [main] DEBUG org.neomatrix369.cli.Main - Unable to suppress JDK9 message
java.lang.ClassNotFoundException: jdk.internal.module.IllegalAccessLogger. This exception was synthesized during native image building from a call to java.lang.Class.forName(String) with a constant class name argument.
at org.neomatrix369.cli.Main.disableAnnoyingJDK9PlusWarning(Main.java:1487)
at org.neomatrix369.cli.Main.main(Main.java:150)
16:57:13.831 [main] WARN org.neomatrix369.cli.Main - Unable to load version properties!
Exception in thread "main" java.lang.UnsupportedOperationException: Class 'org.aeonbits.owner.crypto.IdentityDecryptor' cannot be instantiated; see the cause below in the stack trace
at org.aeonbits.owner.Util.unsupported(Util.java:139)
at org.aeonbits.owner.Util.newInstance(Util.java:273)
at org.aeonbits.owner.PropertiesManager.<init>(PropertiesManager.java:161)
at org.aeonbits.owner.DefaultFactory.create(DefaultFactory.java:43)
at org.aeonbits.owner.ConfigFactory.create(ConfigFactory.java:73)
at org.neomatrix369.cli.Main.displayHelp(Main.java:1431)
at org.neomatrix369.cli.Main.main(Main.java:155)
Caused by: java.lang.InstantiationException: Type `org.aeonbits.owner.crypto.IdentityDecryptor` can not be instantiated reflectively as it does not have a no-parameter constructor or the no-parameter constructor has not been added explicitly to the native image.
at java.lang.Class.newInstance(DynamicHub.java:740)
at org.aeonbits.owner.Util.newInstance(Util.java:271)
... 5 more
Environment:
Darwin manis-MacBook.local 17.7.0 Darwin Kernel Version 17.7.0: Sun Jun 2 20:31:42 PDT 2019; root:xnu-4570.71.46~1/RELEASE_X86_64 x86_64
java -version
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-20190420112649.buildslave.jdk8u-src-tar--b03)
OpenJDK GraalVM CE 19.0.0 (build 25.212-b03-jvmci-19-b01, mixed mode)
I looked at #1163 and #926 and the suggestions there do not help resolve this one. Is this still being worked on?
What's weird with this error is that jdk.internal.module.IllegalAccessLogger is a JDK9+ class and your java is JDK8. Did you compile your app code with a later JDK, i.e., JDK11?
What's weird with this error is that
jdk.internal.module.IllegalAccessLoggeris a JDK9+ class and your java is JDK8. Did you compile your app code with a later JDK, i.e., JDK11?
Good point, I will look into this, and see if I can eliminate it on my end. But if I can't (and this could be an example of an edge-case), then would look up to you guys for some support.
When trying to build a native image from a new uber jar, I get the below message.
I have generated the needed config (in META-INF) file needed using the tracing agent and also manually added an entry.
Command:
OPTIONS="${2:-} --no-fallback --allow-incomplete-classpath --enable-all-security-services --enable-http --enable-https --enable-url-protocols" native-image ${OPTIONS} -jar ${JARFILE} ${IMAGE_NAME}Config (META-INF/native-image) snippet related to the error:
{ "name":"org.aeonbits.owner.crypto.IdentityDecryptor", "methods":[{"name":"<init>","parameterTypes":[] }], "allPublicMethods":true },I have added the above to the
reflect-config.jsonfile but has no effect.Output:
16:57:13.830 [main] DEBUG org.neomatrix369.cli.Main - Unable to suppress JDK9 message java.lang.ClassNotFoundException: jdk.internal.module.IllegalAccessLogger. This exception was synthesized during native image building from a call to java.lang.Class.forName(String) with a constant class name argument. at org.neomatrix369.cli.Main.disableAnnoyingJDK9PlusWarning(Main.java:1487) at org.neomatrix369.cli.Main.main(Main.java:150) 16:57:13.831 [main] WARN org.neomatrix369.cli.Main - Unable to load version properties! Exception in thread "main" java.lang.UnsupportedOperationException: Class 'org.aeonbits.owner.crypto.IdentityDecryptor' cannot be instantiated; see the cause below in the stack trace at org.aeonbits.owner.Util.unsupported(Util.java:139) at org.aeonbits.owner.Util.newInstance(Util.java:273) at org.aeonbits.owner.PropertiesManager.<init>(PropertiesManager.java:161) at org.aeonbits.owner.DefaultFactory.create(DefaultFactory.java:43) at org.aeonbits.owner.ConfigFactory.create(ConfigFactory.java:73) at org.neomatrix369.cli.Main.displayHelp(Main.java:1431) at org.neomatrix369.cli.Main.main(Main.java:155) Caused by: java.lang.InstantiationException: Type `org.aeonbits.owner.crypto.IdentityDecryptor` can not be instantiated reflectively as it does not have a no-parameter constructor or the no-parameter constructor has not been added explicitly to the native image. at java.lang.Class.newInstance(DynamicHub.java:740) at org.aeonbits.owner.Util.newInstance(Util.java:271) ... 5 moreEnvironment:
Darwin manis-MacBook.local 17.7.0 Darwin Kernel Version 17.7.0: Sun Jun 2 20:31:42 PDT 2019; root:xnu-4570.71.46~1/RELEASE_X86_64 x86_64 java -version openjdk version "1.8.0_212" OpenJDK Runtime Environment (build 1.8.0_212-20190420112649.buildslave.jdk8u-src-tar--b03) OpenJDK GraalVM CE 19.0.0 (build 25.212-b03-jvmci-19-b01, mixed mode)I looked at #1163 and #926 and the suggestions there do not help resolve this one. Is this still being worked on?
How do we tackle the second issue:
Exception in thread "main" java.lang.UnsupportedOperationException: Class 'org.aeonbits.owner.crypto.IdentityDecryptor' cannot be instantiated; see the cause below in the stack trace
...
As mentioned, despite the definition in the META-INF reflection config file, we still get this error message.
The latest update is that we are now down to this error message:
14:04:41.578 [main] WARN org.neomatrix369.cli.Main - Unable to load version properties!
Exception in thread "main" java.lang.UnsupportedOperationException: Class 'org.aeonbits.owner.crypto.IdentityDecryptor' cannot be instantiated; see the cause below in the stack trace
at org.aeonbits.owner.Util.unsupported(Util.java:139)
at org.aeonbits.owner.Util.newInstance(Util.java:273)
at org.aeonbits.owner.PropertiesManager.<init>(PropertiesManager.java:161)
at org.aeonbits.owner.DefaultFactory.create(DefaultFactory.java:43)
at org.aeonbits.owner.ConfigFactory.create(ConfigFactory.java:73)
at org.neomatrix369.cli.Main.displayHelp(Main.java:1495)
at org.neomatrix369.cli.Main.main(Main.java:159)
Caused by: java.lang.InstantiationException: Type `org.aeonbits.owner.crypto.IdentityDecryptor` can not be instantiated reflectively as it does not have a no-parameter constructor or the no-parameter constructor has not been added explicitly to the native image.
at java.lang.Class.newInstance(DynamicHub.java:754)
at org.aeonbits.owner.Util.newInstance(Util.java:271)
... 5 more
I get these generated in the reflect-config.json for org.aeonbit related packages:
{
"name":"org.aeonbits.owner.JMXSupport",
"allPublicMethods":true
},
{
"name":"org.aeonbits.owner.PropertiesManager",
"allPublicMethods":true
},
{
"name":"org.aeonbits.owner.crypto.IdentityDecryptor",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
Is this sufficient for the native-image?
Can you try specifying the reflection config file directly via -H:ReflectionConfigurationFiles=/path/to/reflectconfig
to eliminate the possibility that the file is not found?
Can you try specifying the reflection config file directly via
-H:ReflectionConfigurationFiles=/path/to/reflectconfigto eliminate the possibility that the file is not found?
That advice helped, I did that for all the 4 config files:
OPTIONS="${OPTIONS} -H:ReflectionConfigurationFiles=${PWD}/META-INF/native-image/reflect-config.json"
OPTIONS="${OPTIONS} -H:DynamicProxyConfigurationFiles=${PWD}/META-INF/native-image/proxy-config.json"
OPTIONS="${OPTIONS} -H:ResourceConfigurationFiles=${PWD}/META-INF/native-image/resource-config.json"
OPTIONS="${OPTIONS} -H:JNIConfigurationFiles=${PWD}/META-INF/native-image/jni-config.json"
Although I was under the impression native-image detected the META-INF/native-image folder with the config files. if placed next to the jar file.
I can now run the program further, and it now breaks at the below:
Exception in thread "main" java.lang.UnsupportedOperationException: Cannot convert 'false' to java.lang.Boolean
at org.aeonbits.owner.Util.unsupported(Util.java:143)
at org.aeonbits.owner.Converters.unsupportedConversion(Converters.java:296)
at org.aeonbits.owner.Converters.access$500(Converters.java:36)
at org.aeonbits.owner.Converters$12.tryConvert(Converters.java:248)
at org.aeonbits.owner.Converters.doConvert(Converters.java:284)
at org.aeonbits.owner.Converters.convert(Converters.java:279)
at org.aeonbits.owner.PropertiesInvocationHandler.resolveProperty(PropertiesInvocationHandler.java:90)
at org.aeonbits.owner.PropertiesInvocationHandler.invoke(PropertiesInvocationHandler.java:67)
at com.sun.proxy.$Proxy412.doesScanJavascript(Unknown Source)
at org.neomatrix369.cli.Main.isViableFolder(Main.java:420)
at org.neomatrix369.cli.Main.run(Main.java:263)
at org.neomatrix369.cli.Main.main(Main.java:172)
This must be something new.
Although I was under the impression native-image detected the META-INF/native-image folder with the config files. if placed next to the jar file.
META-INF/native-image needs to be inside the jar file. I think META-INF/native-image should also work when is placed next to the code organized in directories, but not archived.
Regarding the error Cannot convert 'false' to java.lang.Boolean, does your code execute successfully on HotSpot?
Regarding the error
Cannot convert 'false' to java.lang.Boolean, does your code execute successfully on HotSpot?
Yes, the uber jar runs fine on traditional JDK (Hotspot) - Java 8.
I'm trying to use the native-image binary to do the same things as the uberjar.
Although I was under the impression native-image detected the META-INF/native-image folder with the config files. if placed next to the jar file.
Placing it next to the jar file has not effect whatsoever. You need to have META-INF/native-image on the classpath. Either by having it right inside your jar file or by adding the parent directory of META-INF to the classpath:
Although I was under the impression native-image detected the META-INF/native-image folder with the config files. if placed next to the jar file.
Placing it next to the jar file has not effect whatsoever. You need to have
META-INF/native-imageon the classpath. Either by having it right inside your jar file or by adding the parent directory ofMETA-INFto the classpath:
From this blog I picked up the below:
The native image generator automatically picks up configuration files in META-INF/native-image or subdirectories, the same way that native-image.properties files are automatically picked up.
Although doing what @cstancu and you suggested fixed the first error.
Regarding the error
Cannot convert 'false' to java.lang.Boolean, does your code execute successfully on HotSpot?
@cstancu
It's this properties files loading library behind the dynamic code generation, see http://owner.aeonbits.org/. Hence we have the error message https://github.com/oracle/graal/issues/1547#issuecomment-516135224
@neomatrix369 can you provide minimal reproducible code?
@neomatrix369 can you provide minimal reproducible code?
@cstancu
aeonbits-example.zip
I have an example attached to this message. Usage:
mvn package./prepareForNativeBuild.sh target/hotreload-jar-with-dependencies.jar./buildNativeImage.sh target/hotreload-jar-with-dependencies.jar And you should see a message like this at the end of the process:
[snipped]
~~~~ Testing built binary hotreload-jar-with-dependencies
HOT RELOAD EXAMPLE
The program is running.
Now you can change the file located at:
/path/to/aeonbits-example/target/examples-generated-resources/HotReloadExample.properties
...and see the changes reflected below
Exception in thread "main" java.lang.UnsupportedOperationException: Cannot convert '10' to java.lang.Integer
at org.aeonbits.owner.Util.unsupported(Util.java:143)
at org.aeonbits.owner.Converters.unsupportedConversion(Converters.java:296)
at org.aeonbits.owner.Converters.access$500(Converters.java:36)
at org.aeonbits.owner.Converters$12.tryConvert(Converters.java:248)
at org.aeonbits.owner.Converters.doConvert(Converters.java:284)
at org.aeonbits.owner.Converters.convert(Converters.java:279)
at org.aeonbits.owner.PropertiesInvocationHandler.resolveProperty(PropertiesInvocationHandler.java:90)
at org.aeonbits.owner.PropertiesInvocationHandler.invoke(PropertiesInvocationHandler.java:67)
at org.aeonbits.owner.examples.$Proxy205.someValue(Unknown Source)
at org.aeonbits.owner.examples.HotReloadExample.main(HotReloadExample.java:69)
Which is synonymous to https://github.com/oracle/graal/issues/1547#issuecomment-516135224
@cstancu is the above good enough for your analysis? Let me know if anything else might help.
@neomatrix369 I'm closing this issue as I don't think it is a bug. I suggest using the Native Image agent to get the complete configuration.
@neomatrix369 I'm closing this issue as I don't think it is a bug. I suggest using the Native Image agent to get the complete configuration.
No worries @cstancu I think this issue is long gone because I was able to rebuild and run the native-image with success, later on, I think the tracing-agent plus some manual config must have helped, it's been a long time since I worked on it. Thank you for following up.
PS: long time no speaks, keep up the good work (and to your team! 馃憦 )