当前位置: 首页 > 知识库问答 >
问题:

无法在OS X Catalina中使用GRAALVM生成本机映像

公良征
2023-03-14

我无法在Catalina 10.15.2中运行命令:

bash-3.2$ $GRAALVM_HOME/Home/bin/gu install native-image 

它向我返回以下消息:

cannot be opened because the developer cannot be verified.

我试过跑步

sudo xattr -r -d com.apple.quarantine $GRAALVM_HOME

哪里

bash-3.2$ echo $GRAALVM_HOME
/Library/Java/JavaVirtualMachines/graalvm-ce-java8-19.3.0/Contents

没有运气。我无法运行该命令,因此无法成功运行该命令

mvn安装-Pnative。

[pastebin][1]

我已经读过这个[帖子][2],对我来说不起作用。

救命啊求你了

更新

好的,我已经应用了建议,现在我可以创建native-image,但是当我尝试运行mvn install-P本国时,我遇到了一个错误:

~/g/q/quarkus-echo> echo $GRAALVM_HOME 
/Library/Java/JavaVirtualMachines/graalvm-ce-java8-19.3.0
aironman@MacBook-Pro-de-Alonso ~/g/q/quarkus-echo> cd $GRAALVM_HOME 
aironman@MacBook-Pro-de-Alonso /L/J/J/graalvm-ce-java8-19.3.0> sudo xattr -r -d com.apple.quarantine $GRAALVM_HOME
Password:
bash-3.2$ /Library/Java/JavaVirtualMachines/graalvm-ce-java8-19.3.0/Contents/Home/bin/gu install native-image
Downloading: Component catalog from www.graalvm.org
Processing Component: Native Image
Downloading: Component native-image: Native Image  from github.com
Installing new component: Native Image (org.graalvm.native-image, version 19.3.0)

bash-3.2$ pwd
/Users/aironman/gitProjects/quarkus-test/quarkus-echo
bash-3.2$ mvn install -Pnative
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------< ujr.combat.quarkus:quarkus-echo >-------------------
[INFO] Building quarkus-echo 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ quarkus-echo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ quarkus-echo ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ quarkus-echo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/aironman/gitProjects/quarkus-test/quarkus-echo/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ quarkus-echo ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.22.1:test (default-test) @ quarkus-echo ---
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running ujr.combat.quarkus.EchoResourceTest
2020-01-13 17:13:45,816 INFO  [io.quarkus] (main) Quarkus 1.1.1.Final started in 0.324s. Listening on: http://0.0.0.0:8081
2020-01-13 17:13:45,829 INFO  [io.quarkus] (main) Profile test activated. 
2020-01-13 17:13:45,829 INFO  [io.quarkus] (main) Installed features: [cdi, resteasy, resteasy-jsonb]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.998 s - in ujr.combat.quarkus.EchoResourceTest
2020-01-13 17:13:46,604 INFO  [io.quarkus] (main) Quarkus stopped in 0.028s
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ quarkus-echo ---
[INFO] 
[INFO] --- quarkus-maven-plugin:1.1.1.Final:build (default) @ quarkus-echo ---
[INFO] [org.jboss.threads] JBoss Threads version 3.0.0.Final
[INFO] [io.quarkus.deployment.pkg.steps.JarResultBuildStep] Building native image source jar: /Users/aironman/gitProjects/quarkus-test/quarkus-echo/target/quarkus-echo-1.0-SNAPSHOT-native-image-source-jar/quarkus-echo-1.0-SNAPSHOT-runner.jar
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Building native image from /Users/aironman/gitProjects/quarkus-test/quarkus-echo/target/quarkus-echo-1.0-SNAPSHOT-native-image-source-jar/quarkus-echo-1.0-SNAPSHOT-runner.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  6.070 s
[INFO] Finished at: 2020-01-13T17:13:48+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:1.1.1.Final:build (default) on project quarkus-echo: Failed to build a runnable JAR: Failed to augment application classes: Build failure: Build failed due to errors
[ERROR]     [error]: Build step io.quarkus.deployment.pkg.steps.NativeImageBuildStep#build threw an exception: java.lang.RuntimeException: Cannot find the `native-image` in the GRAALVM_HOME, JAVA_HOME and System PATH. Install it using `gu install native-image`
[ERROR]     at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.getNativeImageExecutable(NativeImageBuildStep.java:376)
[ERROR]     at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.build(NativeImageBuildStep.java:134)
[ERROR]     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR]     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR]     at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR]     at java.base/java.lang.reflect.Method.invoke(Method.java:567)
[ERROR]     at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:915)
[ERROR]     at io.quarkus.builder.BuildContext.run(BuildContext.java:415)
[ERROR]     at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
[ERROR]     at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2011)
[ERROR]     at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1535)
[ERROR]     at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1426)
[ERROR]     at java.base/java.lang.Thread.run(Thread.java:830)
[ERROR]     at org.jboss.threads.JBossThread.run(JBossThread.java:479)
[ERROR] -> [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
bash-3.2$ echo $GRAALVM_HOME
/Library/Java/JavaVirtualMachines/graalvm-ce-java8-19.3.0
bash-3.2$ 

更新2

经过Viktor的建议,我改变了GRAALVM_HOME:

export GRAALVM_HOME=/Library/Java/JavaVirtualMachines/graalvm-ce-java8-19.3.0/Contents/Home



    bash-3.2$ export GRAALVM_HOME=/Library/Java/JavaVirtualMachines/graalvm-ce-java8-19.3.0/Contents/Home
bash-3.2$ /Library/Java/JavaVirtualMachines/graalvm-ce-java8-19.3.0/Contents/Home/bin/gu install native-image
Downloading: Component catalog from www.graalvm.org
Processing Component: Native Image
Component Native Image (org.graalvm.native-image) is already installed.
bash-3.2$ pwd
/Users/aironman/gitProjects/quarkus-test/quarkus-echo
bash-3.2$ mvn install -Pnative
...
project quarkus-echo: Failed to build a runnable JAR: Failed to augment application classes: Build failure: Build failed due to errors
[ERROR]     [error]: Build step io.quarkus.deployment.pkg.steps.NativeImageBuildStep#build threw an exception: java.lang.IllegalStateException: Unsupported version of GraalVM detected: GraalVM Version 19.3.0 CE. Please use GraalVM 19.2.1.
[ERROR]     at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.checkGraalVMVersion(NativeImageBuildStep.java:340)
[ERROR]     at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.build(NativeImageBuildStep.java:155)
[ERROR]     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR]     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR]     at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR]     at java.base/java.lang.reflect.Method.invoke(Method.java:567)
[ERROR]     at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:915)
[ERROR]     at io.quarkus.builder.BuildContext.run(BuildContext.java:415)
[ERROR]     at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
[ERROR]     at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2011)
[ERROR]     at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1535)
[ERROR]     at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1426)
[ERROR]     at java.base/java.lang.Thread.run(Thread.java:830)
[ERROR]     at org.jboss.threads.JBossThread.run(JBossThread.java:479)
[ERROR] -> [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

看起来我必须降级到GRAALVM 19.2.1。。。

谢谢你们的帮助。我会看看如何使用brew降级到所需版本...

共有3个答案

充浩波
2023-03-14

brew安装——cask graalvm/tap/graalvm-ce-lts-java11

curl-L-ograalvm-ce-java11-darwin-aarch64-22.1.0.tar.gzhttps://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.1.0/graalvm-ce-java11-darwin-aarch64-22.1.0.tar.gz

sudo mv graalvm-ce-java11-22.1.0/Library/Java/JavaVirtualMachines

sudo xattr-r-dcom.apple.quarantine /Library/Java /JavaVirtualMachines/graalvm-ce-lts-java11/Contents/Home

/Library/Java/JavaVirtualMachines/graalvm-ce-lts-java11/Contents/Home/bin/gu安装本机映像

导出GRAALVM_HOME=/Library/Java/JavaVirtualMachines/GRAALVM-ce-lts-java11/Contents/HOME

导出PATH=$PATH:$GRAALVM_HOME

<代码>源~/。zshrc

mvn包-Dquarkus。包裹类型=本机

<代码>/gradlew构建-Dquarkus。包裹类型=本机

东郭弘方
2023-03-14
brew install --cask  graalvm/tap/graalvm-ce-java11
# check your version and fix the last part of path
sudo xattr -r -d com.apple.quarantine /Library/Java/JavaVirtualMachines/graalvm-ce-java11-20.3.0
# install native image
/Library/Java/JavaVirtualMachines/graalvm-ce-java11-20.3.0/Contents/Home/bin/gu install native-image
# don't forget to fix version of GraalVM, yours can be newer
export GRAALVM_HOME=/Library/Java/JavaVirtualMachines/graalvm-ce-java11-20.3.0/Contents/Home
./gradlew build -Dquarkus.package.type=native
芮明知
2023-03-14

您需要在topdir上运行隔离删除:

sudo xattr-r-dcom.apple.quarantine /Library/Java /JavaVirtualMachines/graalvm-ce-java8-19.3.0

 类似资料:
  • 失败:生成失败,出现异常。 错误:执行任务“:QuarkusBuild”失败。Io.Quarkus.Builder.BuildException:生成失败:由于错误导致生成失败[error]:生成步骤Io.Quarkus.Deployment.Pkg.Steps.NativeImageBuildStep#Build引发异常:java.lang.RuntimeException:未能在io.Quar

  • 我在这里将Micronaut应用程序作为Graalvm本地映像进行试用。

  • 我检查了直到Stage-2,本机映像运行得非常好。我包含了Stage-3来运行我的本机映像,结果出现了以下错误 需要帮助如何运行我的本机映像

  • 我正在尝试将我的. jar项目转换为本地映像,因为我需要在不支持Java的设备中运行它。为此,我安装了GraalVM和所有必需的依赖项,本地映像构建工作完美(或者至少看起来是这样,因为它在过程中不会产生任何错误)。 我用于构建的命令是: /usr/lib/jvm/graalvm/bin/native image-jar-MyApp。jar MyApp——启用http——启用https——无回退——

  • 我正在尝试用Dockers创建一个GraalVM本地映像。我已经创建了一个Micronaut项目,并成功创建了jar应用程序,并在docker中运行;此外,我已经用这个jar文件创建了一个GraalVM本机映像,现在可以运行这个应用程序,但我需要在docker中运行一个GraalVM本机映像,在论坛中寻找答案。我发现有必要在docker中构建本机映像。因此我尝试了这个docker文件: 它不会抛出

  • 我正在试图弄清楚如何通过将GraalVM本机映像代理与Quarkus应用程序一起使用。 我试着跑步: 但是我得到了一个错误: 有什么提示吗? 我的Java版本: