Quarkus を使用してサンプル プロジェクトを作成し、MongoDB を追加しました。
JVMを使用して実行する場合、すべてが機能しますが、graalvmを使用してdockerイメージを構築しようとすると、次のエラーが発生しました。
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ quarkus-backend ---
[INFO] Building jar: /home/victor/sources/quarkus-mongo/target/quarkus-backend-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- quarkus-maven-plugin:0.13.3:build (default) @ quarkus-backend ---
[INFO] [io.quarkus.deployment.QuarkusAugmentor] Beginning quarkus augmentation
[INFO] [org.jboss.threads] JBoss Threads version 3.0.0.Alpha4
[INFO] [io.quarkus.deployment.QuarkusAugmentor] Quarkus augmentation completed in 1615ms
[INFO] [io.quarkus.creator.phase.runnerjar.RunnerJarPhase] Building jar: /home/victor/sources/quarkus-mongo/target/quarkus-backend-1.0-SNAPSHOT-runner.jar
[INFO]
[INFO] --- quarkus-maven-plugin:0.13.3:native-image (default) @ quarkus-backend ---
[INFO] [io.quarkus.creator.phase.nativeimage.NativeImagePhase] Running Quarkus native-image plugin on OpenJDK 64-Bit Server VM
[INFO] [io.quarkus.creator.phase.nativeimage.NativeImagePhase] docker run -v /home/victor/sources/quarkus-mongo/target:/project:z --rm --user 1000:1000 quay.io/quarkus/centos-quarkus-native-image:graalvm-1.0.0-rc14 -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager -H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy$BySpaceAndTime -jar quarkus-backend-1.0-SNAPSHOT-runner.jar -J-Djava.util.concurrent.ForkJoinPool.common.parallelism=1 -H:+PrintAnalysisCallTree -H:-AddAllCharsets -H:EnableURLProtocols=http -H:-SpawnIsolates -H:-JNI --no-server -H:-UseServiceLoaderFeature -H:+StackTrace
[quarkus-backend-1.0-SNAPSHOT-runner:9] classlist: 10,109.77 ms
[quarkus-backend-1.0-SNAPSHOT-runner:9] (cap): 2,974.74 ms
[quarkus-backend-1.0-SNAPSHOT-runner:9] setup: 5,274.33 ms
21:14:26,482 INFO [org.xnio] XNIO version 3.7.0.Final
21:14:26,994 INFO [org.xni.nio] XNIO NIO Implementation Version 3.7.0.Final
21:14:32,218 INFO [org.jbo.threads] JBoss Threads version 3.0.0.Alpha4
[quarkus-backend-1.0-SNAPSHOT-runner:9] analysis: 35,833.87 ms
Printing call tree to /project/reports/call_tree_quarkus-backend-1.0-SNAPSHOT-runner_20190504_211458.txt
Printing list of used classes to /project/reports/used_classes_quarkus-backend-1.0-SNAPSHOT-runner_20190504_211501.txt
Printing list of used packages to /project/reports/used_packages_quarkus-backend-1.0-SNAPSHOT-runner_20190504_211502.txt
Error: unsupported features in 6 methods
Detailed message:
Error: Class initialization failed: com.mongodb.UnixServerAddress
Original exception that caused the problem: java.lang.NoClassDefFoundError: jnr/unixsocket/UnixSocketAddress
at sun.misc.Unsafe.ensureClassInitialized(Native Method)
at com.oracle.svm.hosted.ClassInitializationSupportImpl.ensureClassInitialized(ClassInitializationSupportImpl.java:199)
at com.oracle.svm.hosted.ClassInitializationSupportImpl.computeInitKindAndMaybeInitializeClass(ClassInitializationSupportImpl.java:162)
at com.oracle.svm.hosted.ClassInitializationSupportImpl.computeInitKindAndMaybeInitializeClass(ClassInitializationSupportImpl.java:138)
at com.oracle.svm.hosted.ClassInitializationSupportImpl.maybeInitializeHosted(ClassInitializationSupportImpl.java:103)
at com.oracle.svm.hosted.SVMHost.registerType(SVMHost.java:179)
at com.oracle.graal.pointsto.meta.AnalysisUniverse.createType(AnalysisUniverse.java:263)
at com.oracle.graal.pointsto.meta.AnalysisUniverse.lookupAllowUnresolved(AnalysisUniverse.java:204)
at com.oracle.graal.pointsto.infrastructure.WrappedConstantPool.lookupType(WrappedConstantPool.java:154)
at org.graalvm.compiler.java.BytecodeParser.lookupType(BytecodeParser.java:3992)
at org.graalvm.compiler.java.BytecodeParser.genNewInstance(BytecodeParser.java:4235)
at org.graalvm.compiler.java.BytecodeParser.processBytecode(BytecodeParser.java:5023)
at org.graalvm.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:3184)
at org.graalvm.compiler.java.BytecodeParser.processBlock(BytecodeParser.java:2993)
at org.graalvm.compiler.java.BytecodeParser.build(BytecodeParser.java:891)
at org.graalvm.compiler.java.BytecodeParser.buildRootMethod(BytecodeParser.java:785)
at org.graalvm.compiler.java.GraphBuilderPhase$Instance.run(GraphBuilderPhase.java:95)
at org.graalvm.compiler.phases.Phase.run(Phase.java:49)
at org.graalvm.compiler.phases.BasePhase.apply(BasePhase.java:197)
at org.graalvm.compiler.phases.Phase.apply(Phase.java:42)
at org.graalvm.compiler.phases.Phase.apply(Phase.java:38)
at com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.parse(MethodTypeFlowBuilder.java:213)
at com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.apply(MethodTypeFlowBuilder.java:332)
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.flow.StaticInvokeTypeFlow.update(InvokeTypeFlow.java:346)
at com.oracle.graal.pointsto.BigBang$2.run(BigBang.java:508)
at com.oracle.graal.pointsto.util.CompletionExecutor.lambda$execute$0(CompletionExecutor.java:169)
at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402)
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: jnr.unixsocket.UnixSocketAddress
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 34 more
Error: Class initialization failed: com.mongodb.internal.connection.SnappyCompressor
Original exception that caused the problem: java.lang.NoClassDefFoundError: org/xerial/snappy/SnappyInputStream
at sun.misc.Unsafe.ensureClassInitialized(Native Method)
at com.oracle.svm.hosted.ClassInitializationSupportImpl.ensureClassInitialized(ClassInitializationSupportImpl.java:199)
at com.oracle.svm.hosted.ClassInitializationSupportImpl.computeInitKindAndMaybeInitializeClass(ClassInitializationSupportImpl.java:162)
at com.oracle.svm.hosted.ClassInitializationSupportImpl.computeInitKindAndMaybeInitializeClass(ClassInitializationSupportImpl.java:138)
at com.oracle.svm.hosted.ClassInitializationSupportImpl.maybeInitializeHosted(ClassInitializationSupportImpl.java:103)
at com.oracle.svm.hosted.SVMHost.registerType(SVMHost.java:179)
at com.oracle.graal.pointsto.meta.AnalysisUniverse.createType(AnalysisUniverse.java:263)
at com.oracle.graal.pointsto.meta.AnalysisUniverse.lookupAllowUnresolved(AnalysisUniverse.java:204)
at com.oracle.graal.pointsto.infrastructure.WrappedConstantPool.lookupType(WrappedConstantPool.java:154)
at org.graalvm.compiler.java.BytecodeParser.lookupType(BytecodeParser.java:3992)
at org.graalvm.compiler.java.BytecodeParser.genNewInstance(BytecodeParser.java:4235)
at org.graalvm.compiler.java.BytecodeParser.processBytecode(BytecodeParser.java:5023)
at org.graalvm.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:3184)
at org.graalvm.compiler.java.BytecodeParser.processBlock(BytecodeParser.java:2993)
at org.graalvm.compiler.java.BytecodeParser.build(BytecodeParser.java:891)
at org.graalvm.compiler.java.BytecodeParser.buildRootMethod(BytecodeParser.java:785)
at org.graalvm.compiler.java.GraphBuilderPhase$Instance.run(GraphBuilderPhase.java:95)
at org.graalvm.compiler.phases.Phase.run(Phase.java:49)
at org.graalvm.compiler.phases.BasePhase.apply(BasePhase.java:197)
at org.graalvm.compiler.phases.Phase.apply(Phase.java:42)
at org.graalvm.compiler.phases.Phase.apply(Phase.java:38)
at com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.parse(MethodTypeFlowBuilder.java:213)
at com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.apply(MethodTypeFlowBuilder.java:332)
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.flow.SpecialInvokeTypeFlow.onObservedUpdate(InvokeTypeFlow.java:421)
at com.oracle.graal.pointsto.flow.TypeFlow.notifyObservers(TypeFlow.java:352)
at com.oracle.graal.pointsto.flow.TypeFlow.update(TypeFlow.java:394)
at com.oracle.graal.pointsto.BigBang$2.run(BigBang.java:508)
at com.oracle.graal.pointsto.util.CompletionExecutor.lambda$execute$0(CompletionExecutor.java:169)
at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402)
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: org.xerial.snappy.SnappyInputStream
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 36 more
Error: Class initialization failed: com.mongodb.internal.connection.UnixSocketChannelStream
Original exception that caused the problem: java.lang.NoClassDefFoundError: jnr/unixsocket/UnixSocketChannel
at sun.misc.Unsafe.ensureClassInitialized(Native Method)
at com.oracle.svm.hosted.ClassInitializationSupportImpl.ensureClassInitialized(ClassInitializationSupportImpl.java:199)
at com.oracle.svm.hosted.ClassInitializationSupportImpl.computeInitKindAndMaybeInitializeClass(ClassInitializationSupportImpl.java:162)
at com.oracle.svm.hosted.ClassInitializationSupportImpl.computeInitKindAndMaybeInitializeClass(ClassInitializationSupportImpl.java:138)
at com.oracle.svm.hosted.ClassInitializationSupportImpl.maybeInitializeHosted(ClassInitializationSupportImpl.java:103)
at com.oracle.svm.hosted.SVMHost.registerType(SVMHost.java:179)
at com.oracle.graal.pointsto.meta.AnalysisUniverse.createType(AnalysisUniverse.java:263)
at com.oracle.graal.pointsto.meta.AnalysisUniverse.lookupAllowUnresolved(AnalysisUniverse.java:204)
at com.oracle.graal.pointsto.infrastructure.WrappedConstantPool.lookupType(WrappedConstantPool.java:154)
at org.graalvm.compiler.java.BytecodeParser.lookupType(BytecodeParser.java:3992)
at org.graalvm.compiler.java.BytecodeParser.genNewInstance(BytecodeParser.java:4235)
at org.graalvm.compiler.java.BytecodeParser.processBytecode(BytecodeParser.java:5023)
at org.graalvm.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:3184)
at org.graalvm.compiler.java.BytecodeParser.processBlock(BytecodeParser.java:2993)
at org.graalvm.compiler.java.BytecodeParser.build(BytecodeParser.java:891)
at org.graalvm.compiler.java.BytecodeParser.buildRootMethod(BytecodeParser.java:785)
at org.graalvm.compiler.java.GraphBuilderPhase$Instance.run(GraphBuilderPhase.java:95)
at org.graalvm.compiler.phases.Phase.run(Phase.java:49)
at org.graalvm.compiler.phases.BasePhase.apply(BasePhase.java:197)
at org.graalvm.compiler.phases.Phase.apply(Phase.java:42)
at org.graalvm.compiler.phases.Phase.apply(Phase.java:38)
at com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.parse(MethodTypeFlowBuilder.java:213)
at com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.apply(MethodTypeFlowBuilder.java:332)
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:191)
at com.oracle.graal.pointsto.flow.TypeFlow.notifyObservers(TypeFlow.java:352)
at com.oracle.graal.pointsto.flow.TypeFlow.update(TypeFlow.java:394)
at com.oracle.graal.pointsto.BigBang$2.run(BigBang.java:508)
at com.oracle.graal.pointsto.util.CompletionExecutor.lambda$execute$0(CompletionExecutor.java:169)
at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402)
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: jnr.unixsocket.UnixSocketChannel
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 36 more
Error: com.oracle.graal.pointsto.constraints.UnresolvedElementException: Discovered unresolved method during parsing: com.mongodb.UnixServerAddress.<init>(java.lang.String). To diagnose the issue you can use the --allow-incomplete-classpath option. The missing method is then reported at run time when it is accessed the first time.
Trace:
at parsing com.mongodb.internal.connection.ServerAddressHelper.createServerAddress(ServerAddressHelper.java:31)
Call path from entry point to com.mongodb.internal.connection.ServerAddressHelper.createServerAddress(String, int):
at com.mongodb.internal.connection.ServerAddressHelper.createServerAddress(ServerAddressHelper.java:30)
at com.mongodb.internal.connection.ServerAddressHelper.createServerAddress(ServerAddressHelper.java:26)
at com.mongodb.internal.connection.DefaultDnsSrvRecordMonitor$DnsSrvRecordMonitorRunnable.createServerAddressSet(DefaultDnsSrvRecordMonitor.java:124)
at com.mongodb.internal.connection.DefaultDnsSrvRecordMonitor$DnsSrvRecordMonitorRunnable.run(DefaultDnsSrvRecordMonitor.java:78)
at java.lang.Thread.run(Thread.java:748)
at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:473)
at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:193)
at com.oracle.svm.core.code.IsolateEnterStub.PosixJavaThreads_pthreadStartRoutine_e1f4a8c0039f8337338252cd8734f63a79b5e3df(generated:0)
--------------------------------------------------------------------------------------------
-- WARNING: The above stack trace is not a real stack trace, it is a theoretical call tree---
-- If an interface has multiple implementations SVM will just display one potential call ---
-- path to the interface. This is often meaningless, and what you actually need to know is---
-- the path to the constructor of the object that implements this interface. ---
-- Quarkus has attempted to generate a more meaningful call flow analysis below ---
---------------------------------------------------------------------------------------------
Error: com.oracle.graal.pointsto.constraints.UnresolvedElementException: Discovered unresolved method during parsing: com.mongodb.internal.connection.SnappyCompressor.<init>(). To diagnose the issue you can use the --allow-incomplete-classpath option. The missing method is then reported at run time when it is accessed the first time.
Trace:
at parsing com.mongodb.internal.connection.InternalStreamConnection.createCompressor(InternalStreamConnection.java:209)
Call path from entry point to com.mongodb.internal.connection.InternalStreamConnection.createCompressor(MongoCompressor):
at com.mongodb.internal.connection.InternalStreamConnection.createCompressor(InternalStreamConnection.java:206)
at com.mongodb.internal.connection.InternalStreamConnection.createCompressorMap(InternalStreamConnection.java:183)
at com.mongodb.internal.connection.InternalStreamConnection.<init>(InternalStreamConnection.java:110)
at com.mongodb.internal.connection.InternalStreamConnectionFactory.create(InternalStreamConnectionFactory.java:56)
at com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:115)
at java.lang.Thread.run(Thread.java:748)
at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:473)
at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:193)
at com.oracle.svm.core.code.IsolateEnterStub.PosixJavaThreads_pthreadStartRoutine_e1f4a8c0039f8337338252cd8734f63a79b5e3df(generated:0)
--------------------------------------------------------------------------------------------
-- WARNING: The above stack trace is not a real stack trace, it is a theoretical call tree---
-- If an interface has multiple implementations SVM will just display one potential call ---
-- path to the interface. This is often meaningless, and what you actually need to know is---
-- the path to the constructor of the object that implements this interface. ---
-- Quarkus has attempted to generate a more meaningful call flow analysis below ---
---------------------------------------------------------------------------------------------
Error: com.oracle.graal.pointsto.constraints.UnresolvedElementException: Discovered unresolved method during parsing: com.mongodb.internal.connection.UnixSocketChannelStream.<init>(com.mongodb.UnixServerAddress, com.mongodb.connection.SocketSettings, com.mongodb.connection.SslSettings, com.mongodb.connection.BufferProvider). To diagnose the issue you can use the --allow-incomplete-classpath option. The missing method is then reported at run time when it is accessed the first time.
Trace:
at parsing com.mongodb.connection.SocketStreamFactory.create(SocketStreamFactory.java:76)
Call path from entry point to com.mongodb.connection.SocketStreamFactory.create(ServerAddress):
at com.mongodb.connection.SocketStreamFactory.create(SocketStreamFactory.java:72)
at com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:124)
at com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:117)
at java.lang.Thread.run(Thread.java:748)
at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:473)
at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:193)
at com.oracle.svm.core.code.IsolateEnterStub.PosixJavaThreads_pthreadStartRoutine_e1f4a8c0039f8337338252cd8734f63a79b5e3df(generated:0)
--------------------------------------------------------------------------------------------
-- WARNING: The above stack trace is not a real stack trace, it is a theoretical call tree---
-- If an interface has multiple implementations SVM will just display one potential call ---
-- path to the interface. This is often meaningless, and what you actually need to know is---
-- the path to the constructor of the object that implements this interface. ---
-- Quarkus has attempted to generate a more meaningful call flow analysis below ---
---------------------------------------------------------------------------------------------
Error: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception
Error: Image building with exit status 1
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:19 min
[INFO] Finished at: 2019-05-04T18:15:04-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:0.13.3:native-image (default) on project quarkus-backend: Failed to generate a native image: Failed to build native image: Image generation failed -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
このエラーを修正するにはどうすればよいですか? すべての依存関係を pom.xml に追加しようとしましたが、うまくいかないようです。
エラーを作成するには、次を実行します。
mvn package -Pnative -Dnative-image.docker-build=true
テスト用のコードは、github vepo/quarkus-mongo にあります。