https://bz.apache.org/bugzilla/show_bug.cgi?id=64875
Bug ID: 64875
Summary: ClassNotFoundException with GraalVM and JNI
Product: Tomcat 9
Version: 9.0.x
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P2
Component: Catalina
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: -----
I have upgraded Tomcat integration in Micronaut to 9.0.39 (from 9.0.38) and
GraalVM native image generation fails because of this issue:
"Remove the entry for org.apache.tomcat.util.descriptor.tld.LocalStrings from
tomcat-embed-core's GraalVM tomcat-resource.json. It no more part of the jar
since Fix unwanted JPMS dependency of embed-core on embed-jasper. (mgrigorov)"
As the issue is fixed in the snapshot version (9.0.40-dev) I've tried it but
now the native image generation fails with:
[servlet-tomcat:27563] classlist: 7,251.57 ms, 2.41 GB
[servlet-tomcat:27563] (cap): 707.30 ms, 2.41 GB
[servlet-tomcat:27563] setup: 2,172.74 ms, 2.41 GB
[servlet-tomcat:27563] (clinit): 1,285.16 ms, 3.67 GB
[servlet-tomcat:27563] (typeflow): 37,093.14 ms, 3.67 GB
[servlet-tomcat:27563] (objects): 30,955.12 ms, 3.67 GB
[servlet-tomcat:27563] (features): 1,939.07 ms, 3.67 GB
[servlet-tomcat:27563] analysis: 73,590.13 ms, 3.67 GB
[servlet-tomcat:27563] universe: 3,140.35 ms, 3.72 GB
Fatal error:java.lang.NoClassDefFoundError
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:598)
at java.util.concurrent.ForkJoinTask.get(ForkJoinTask.java:1005)
at
com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:483)
at
com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:350)
at
com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:509)
at
com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:115)
Caused by: java.lang.NoClassDefFoundError:
io/netty/internal/tcnative/SSLPrivateKeyMethod
at jdk.vm.ci.hotspot.CompilerToVM.getDeclaredMethods(Native Method)
at
jdk.vm.ci.hotspot.HotSpotResolvedObjectTypeImpl.getDeclaredMethods(HotSpotResolvedObjectTypeImpl.java:973)
at
com.oracle.svm.jni.access.JNIAccessibleMethod.anyMatchIgnoreReturnType(JNIAccessibleMethod.java:139)
at
com.oracle.svm.jni.access.JNIAccessibleMember.findHidingSubclasses(JNIAccessibleMember.java:103)
at
com.oracle.svm.jni.access.JNIAccessibleMember.findHidingSubclasses(JNIAccessibleMember.java:110)
at
com.oracle.svm.jni.access.JNIAccessibleMember.setHidingSubclasses(JNIAccessibleMember.java:83)
at
com.oracle.svm.jni.access.JNIAccessibleMethod.finishBeforeCompilation(JNIAccessibleMethod.java:135)
at
com.oracle.svm.jni.access.JNIAccessFeature.beforeCompilation(JNIAccessFeature.java:350)
at
com.oracle.svm.hosted.NativeImageGenerator.lambda$doRun$2(NativeImageGenerator.java:614)
at
com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:70)
at
com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:614)
at
com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:471)
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)
Caused by: java.lang.ClassNotFoundException:
io.netty.internal.tcnative.SSLPrivateKeyMethod
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 17 more
I've been taking a look at the changes done from 9.0.39 and this commit
https://github.com/apache/tomcat/commit/6287552d9a14b698990954c6591f5f8512bc4a78
broke the generation. I've tried to build tomcat locally and it worked, but I
don't know how to publish it to my local maven. So what I've done is manually
modifying the downloaded .jar file and removing the `tomcat-jni.json`
introduced in that commit. That fixed the native image generation.
You can see that I'm running 9.0.40-dev version:
$ ./servlet-tomcat
Nov 05, 2020 12:18:28 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8080"]
Nov 05, 2020 12:18:28 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service [Tomcat]
Nov 05, 2020 12:18:28 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet engine: [Apache Tomcat/9.0.40-dev] <----- See this
Nov 05, 2020 12:18:28 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]
12:18:28.480 [main] INFO io.micronaut.runtime.Micronaut - Startup completed in
17ms. Server Running: http://localhost:8080
Is there a way to disable all that JNI stuff if I don't need it? Maybe that
configuration should be generated by a GraalVM @AutomaticFeature instead of
always adding it.
Thanks!
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]