Description
I'm trying to build a native image for a Java microservice project that uses CDI.
I'm struggling in an weird error even with -H:+ReportUnsupportedElementsAtRuntime
set.
The stacktrace doesn't help me to identify what's happening.
Error: Detected a ZipFile object in the image heap. This is not supported. The object was reached from a static initializer. All static class initialization is done during native image construction, thus a static initializer cannot contain code that captures state dependent on the build machine. Write your own initialization methods and call them explicitly from your main entry point.
Trace: object java.util.HashMap$Node
object java.util.HashMap$Node[]
object java.util.HashMap
method sun.net.www.protocol.jar.JarFileFactory.get(URL, boolean)
Call path from entry point to sun.net.www.protocol.jar.JarFileFactory.get(URL, boolean):
at sun.net.www.protocol.jar.JarFileFactory.get(JarFileFactory.java:79)
at sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:122)
at sun.net.www.protocol.jar.JarURLConnection.getInputStream(JarURLConnection.java:152)
at java.net.URL.openStream(URL.java:1045)
at java.util.ServiceLoader.parse(ServiceLoader.java:304)
at java.util.ServiceLoader.access$200(ServiceLoader.java:185)
at java.util.ServiceLoader$LazyIterator.hasNextService(ServiceLoader.java:357)
at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:364)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
at ws.ament.hammock.Bootstrap.main(Bootstrap.java:40)
at com.oracle.svm.reflect.proxies.Proxy_1_Bootstrap_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)
This error happens with two CDI implementations: Weld and OpenWebBeans.
Weld verbose log.
OpenWebBeans verbose log.
The source code and instructions are available at:
https://github.com/panga/hammock-graal.git
BTW I see an annoying pattern adding Service Provider classes contructor into ReflectionConfigurationFiles (e.g: https://github.com/panga/hammock-graal/blob/master/reflection-owb.json) why it's not automatically detected by SubstrateVM ?
Example: ServiceLoader.load(Bootstrapper.class)
SubstrateVM detects the classes but fails when try to instantiate them.