Cloud Foundry java buildpack - java: 找不到命令
Cloud Foundry java buildpack - java: command not found
Cloud Foundry 的新手,使用 java buildpack 推送 java 应用程序的 zip 分发。它正确检测到启动脚本,但是当启动脚本到达需要启动 jvm 的位置时,我收到此错误:
bash: java: command not found
显然 'java' 在脚本执行期间不在 shell 的路径上,而且我在任何地方都找不到 JAVA_HOME 定义。
用于启动 java 应用程序的路径是什么?
它在哪里记录?
误报
非常感谢@DanielMikusa 指出 JAVA_HOME 确实已设置,即使在使用的 buildpack 的相当旧的版本中也是如此。这里没什么可看的。
编辑#1
我发现当启动脚本启动时,$PWD/.buildpack-java/oracle_jre
中有一个 jre。但是,这不可能是我期望用来指定 JAVA_HOME
路径的内容,对吗?这个位置似乎完全取决于 java 构建包的当前实现。似乎 jre 的 bin 文件夹应该在启动脚本的进程路径中,或者应该有一个环境变量或在 运行 启动脚本之前建立的其他配置,这样我就可以使用该值来查找 java可执行文件。
编辑 #2
以下是 cf 推送操作期间的输出:
PS E:\dev\hoobajoob\myproject\build\distributions> cf push -p .\my-service-1.0.0.zip my-service
Using manifest file E:\dev\hoobajoob\myproject\build\distributions\manifest.yml
Creating app my-service in org DEV / space dev as chefhoobajoob@github.com...
OK
Creating route my-service.cflab.dctmlabs.com...
OK
Binding my-service.cflab.dctmlabs.com to my-service...
OK
Uploading my-service...
Uploading app files from: C:\Users\hoobajoob\AppData\Local\Temp\unzipped-app384867239
Uploading 9.7M, 9390 files
Done uploading
OK
Starting app my-service in org DEV / space dev as chefhoobajoob@github.com...
Downloading oracle_buildpack_151...
Downloading binary_buildpack...
Downloading go_buildpack...
Downloading python_buildpack...
Downloading java-buildpack-offline-v3-19-2...
Downloaded java-buildpack-offline-v3-19-2
Downloading java-buildpack-offline-4-7...
...<more downloads>
Creating container
Successfully created container
Downloading app package...
Downloaded app package (53.1M)
Staging...
-----> Java Buildpack Version: v3.5.1 (offline) | https://github.com/cloudfoundry/java-buildpack.git#3abc3db
-----> Downloading Oracle JRE 1.8.0_112 from http://127.0.0.1/oracle-jre/trusty/x86_64/jre-8u112-linux-x64.tar.gz (found
in cache)
Expanding Oracle JRE to .java-buildpack/oracle_jre (2.3s)
-----> Downloading Open JDK Like Memory Calculator 2.0.1_RELEASE from https://download.run.pivotal.io/memory-calculator/
trusty/x86_64/memory-calculator-2.0.1_RELEASE.tar.gz (found in cache)
Memory Settings: -Xms2304M -XX:MetaspaceSize=314572K -Xss1M -Xmx2304M -XX:MaxMetaspaceSize=314572K
-----> Downloading Spring Auto Reconfiguration 1.10.0_RELEASE from https://download.run.pivotal.io/auto-reconfiguration/
auto-reconfiguration-1.10.0_RELEASE.jar (found in cache)
Exit status 0
Staging complete
Uploading droplet, build artifacts cache...
Uploading droplet...
Uploading build artifacts cache...
Uploaded build artifacts cache (108B)
Uploaded droplet (120.5M)
Uploading complete
Destroying container
Successfully destroyed container
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
1 of 1 instances running
App started
OK
App my-service was started using this command `CALCULATED_MEMORY=$($PWD/.java-buildpack/oracle_jre/bin/java-buildpack-memory-calculator-2.0.1_RELEASE -memorySizes=metaspace:64m.. -memoryWeights=heap:75,metaspace:10,native:10,stack:5 -memoryInitials=heap:100%,metaspace:100% -totMemory=$MEMORY_LIMIT) && JAVA_HOME=$PWD/.java-buildpack/oracle_jre JAVA_OPTS="-Djava.io.tmpdir=$TMPDIR -XX:OnOutOfMemoryError=$PWD/.java-buildpack/oracle_jre/bin/killjava.sh $CALCULATED_MEMORY" exec $PWD/my-service-1.0.0/bin/launch`
写下上面的评论以防其他人遇到这个问题。
- 我们查看了暂存的完整输出和 Java buildpack 生成的启动命令。
- 我们可以从 Java 构建包生成的启动命令中看出,启动命令负责设置 JAVA_HOME。
- 如果您依赖 Java buildpack 为您的 dist-zip 样式应用程序创建启动命令,它将 "do the right thing" 和 add the JAVA_HOME environment variable 包含启动命令的正确路径.
- 如果您需要创建自定义启动命令,您有责任正确设置 JAVA_HOME。
- 如果您
cf ssh
进入由 Java buildpack 启动的应用程序,则您有责任设置 JAVA_HOME.
Cloud Foundry 的新手,使用 java buildpack 推送 java 应用程序的 zip 分发。它正确检测到启动脚本,但是当启动脚本到达需要启动 jvm 的位置时,我收到此错误:
bash: java: command not found
显然 'java' 在脚本执行期间不在 shell 的路径上,而且我在任何地方都找不到 JAVA_HOME 定义。
用于启动 java 应用程序的路径是什么? 它在哪里记录?
误报
非常感谢@DanielMikusa 指出 JAVA_HOME 确实已设置,即使在使用的 buildpack 的相当旧的版本中也是如此。这里没什么可看的。
编辑#1
我发现当启动脚本启动时,$PWD/.buildpack-java/oracle_jre
中有一个 jre。但是,这不可能是我期望用来指定 JAVA_HOME
路径的内容,对吗?这个位置似乎完全取决于 java 构建包的当前实现。似乎 jre 的 bin 文件夹应该在启动脚本的进程路径中,或者应该有一个环境变量或在 运行 启动脚本之前建立的其他配置,这样我就可以使用该值来查找 java可执行文件。
编辑 #2
以下是 cf 推送操作期间的输出:
PS E:\dev\hoobajoob\myproject\build\distributions> cf push -p .\my-service-1.0.0.zip my-service
Using manifest file E:\dev\hoobajoob\myproject\build\distributions\manifest.yml
Creating app my-service in org DEV / space dev as chefhoobajoob@github.com...
OK
Creating route my-service.cflab.dctmlabs.com...
OK
Binding my-service.cflab.dctmlabs.com to my-service...
OK
Uploading my-service...
Uploading app files from: C:\Users\hoobajoob\AppData\Local\Temp\unzipped-app384867239
Uploading 9.7M, 9390 files
Done uploading
OK
Starting app my-service in org DEV / space dev as chefhoobajoob@github.com...
Downloading oracle_buildpack_151...
Downloading binary_buildpack...
Downloading go_buildpack...
Downloading python_buildpack...
Downloading java-buildpack-offline-v3-19-2...
Downloaded java-buildpack-offline-v3-19-2
Downloading java-buildpack-offline-4-7...
...<more downloads>
Creating container
Successfully created container
Downloading app package...
Downloaded app package (53.1M)
Staging...
-----> Java Buildpack Version: v3.5.1 (offline) | https://github.com/cloudfoundry/java-buildpack.git#3abc3db
-----> Downloading Oracle JRE 1.8.0_112 from http://127.0.0.1/oracle-jre/trusty/x86_64/jre-8u112-linux-x64.tar.gz (found
in cache)
Expanding Oracle JRE to .java-buildpack/oracle_jre (2.3s)
-----> Downloading Open JDK Like Memory Calculator 2.0.1_RELEASE from https://download.run.pivotal.io/memory-calculator/
trusty/x86_64/memory-calculator-2.0.1_RELEASE.tar.gz (found in cache)
Memory Settings: -Xms2304M -XX:MetaspaceSize=314572K -Xss1M -Xmx2304M -XX:MaxMetaspaceSize=314572K
-----> Downloading Spring Auto Reconfiguration 1.10.0_RELEASE from https://download.run.pivotal.io/auto-reconfiguration/
auto-reconfiguration-1.10.0_RELEASE.jar (found in cache)
Exit status 0
Staging complete
Uploading droplet, build artifacts cache...
Uploading droplet...
Uploading build artifacts cache...
Uploaded build artifacts cache (108B)
Uploaded droplet (120.5M)
Uploading complete
Destroying container
Successfully destroyed container
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
1 of 1 instances running
App started
OK
App my-service was started using this command `CALCULATED_MEMORY=$($PWD/.java-buildpack/oracle_jre/bin/java-buildpack-memory-calculator-2.0.1_RELEASE -memorySizes=metaspace:64m.. -memoryWeights=heap:75,metaspace:10,native:10,stack:5 -memoryInitials=heap:100%,metaspace:100% -totMemory=$MEMORY_LIMIT) && JAVA_HOME=$PWD/.java-buildpack/oracle_jre JAVA_OPTS="-Djava.io.tmpdir=$TMPDIR -XX:OnOutOfMemoryError=$PWD/.java-buildpack/oracle_jre/bin/killjava.sh $CALCULATED_MEMORY" exec $PWD/my-service-1.0.0/bin/launch`
写下上面的评论以防其他人遇到这个问题。
- 我们查看了暂存的完整输出和 Java buildpack 生成的启动命令。
- 我们可以从 Java 构建包生成的启动命令中看出,启动命令负责设置 JAVA_HOME。
- 如果您依赖 Java buildpack 为您的 dist-zip 样式应用程序创建启动命令,它将 "do the right thing" 和 add the JAVA_HOME environment variable 包含启动命令的正确路径.
- 如果您需要创建自定义启动命令,您有责任正确设置 JAVA_HOME。
- 如果您
cf ssh
进入由 Java buildpack 启动的应用程序,则您有责任设置 JAVA_HOME.