无法在 openjdk 中使用 arthas 时在 java 主目录下找到 tools.jar 文件。

huangapple go评论103阅读模式
英文:

Can not find tools.jar under java home when using arthas in openjdk

问题

以下是翻译的内容:

我在Kubernetes的Docker容器中使用arthas 3.3.6与openjdk8,当我启动arthas时,显示如下:

/opt/arthas # java -jar arthas-boot.jar 1
[INFO] arthas-boot版本:3.3.6
[INFO] arthas主目录:/opt/arthas
[INFO] 尝试附加到进程1
Exception in thread "main" java.lang.IllegalArgumentException:无法在Java主目录下找到tools.jar:/usr/lib/jvm/java-1.8-openjdk/jre,请尝试使用完整路径启动arthas-boot。例如:/opt/jdk/bin/java -jar arthas-boot.jar
        at com.taobao.arthas.boot.ProcessUtils.findJavaHome(ProcessUtils.java:222)
        at com.taobao.arthas.boot.ProcessUtils.startArthasCore(ProcessUtils.java:233)
        at com.taobao.arthas.boot.Bootstrap.main(Bootstrap.java:515)

然后我下载了Oracle JDK并出现了以下错误:

/opt/arthas # /opt/jdk1.8.0_211/bin/java -jar arthas-boot.jar
sh: /opt/jdk1.8.0_211/bin/java: 未找到命令

我在互联网上搜索并得知OracleJDK的C库与Alpine不兼容。有人将tools.jar复制到Docker容器中,但仍未解决此问题。那么我应该如何使arthas正常工作呢?

英文:

I am using arthas 3.3.6 in kubernetes docker container with openjdk8, when I start arthas, it shows:

/opt/arthas # java -jar arthas-boot.jar 1
[INFO] arthas-boot version: 3.3.6
[INFO] arthas home: /opt/arthas
[INFO] Try to attach process 1
Exception in thread "main" java.lang.IllegalArgumentException: Can not find tools.jar under java home: /usr/lib/jvm/java-1.8-openjdk/jre, please try to start arthas-boot with full path java. Such as /opt/jdk/bin/java -jar arthas-boot.jar
        at com.taobao.arthas.boot.ProcessUtils.findJavaHome(ProcessUtils.java:222)
        at com.taobao.arthas.boot.ProcessUtils.startArthasCore(ProcessUtils.java:233)
        at com.taobao.arthas.boot.Bootstrap.main(Bootstrap.java:515)

then I download the oracle JDK and throw this error:

  /opt/arthas # /opt/jdk1.8.0_211/bin/java -jar arthas-boot.jar
sh: /opt/jdk1.8.0_211/bin/java: not found

I am searching from internet and tell me the OracleJDK C lib is imcompatible with alpine.someone copy the tools.jar into docker container still not fix this problem. so what should I do to make arthas works?

答案1

得分: 1

我思考过这个问题,除了切换docker文件的基础镜像之外,可能还有两个解决方案:

  • 目标进程的JVM是openjdk的JRE,而不是JDK。没有tools.jar。您可以在启动Arthas时手动指定tools.jar的路径

    java -jar arthas-boot.jar -Dtools.jar=./tools.jar

  • 重新安装JDK,并将JAVA_HOME设置为带有tools JDK目录的新目录。

  • 将基础镜像更改为openjdk:8,就像您的解决方案一样。

英文:

I thought about this question,Maybe there are two solutions besides switching the base image of docker file:

  • The JVM of the target process is the JRE of openjdk, not JDK. There is no tools.jar. You can manually specify the path of tools.jar when starting Arthas

    java -jar arthas-boot.jar -Dtools.jar=./tools.jar

  • Reinstall JDK and set JAVA_HOME is new with tools JDK directory of jar.

  • Change the base image to openjdk:8. just like your solution.

答案2

得分: 0

更改基础镜像为 openjdk:8

FROM openjdk:8

运行正常。

英文:

change the base image to openjdk:8.

FROM openjdk:8

works.

huangapple
  • 本文由 发表于 2020年9月7日 17:24:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/63774795.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定