Cloud Foundry java buildpack - java:command not found

时间:2018-01-09 18:35:34

标签: java cloudfoundry buildpack

云代工厂的新手,使用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 buildpack的当前实现。似乎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`

1 个答案:

答案 0 :(得分:0)

如果其他人遇到此问题,请写上面的评论。

  1. 我们查看了staging的完整输出以及Java buildpack生成的启动命令。
  2. 我们可以从Java buildpack生成的start命令中看到启动命令负责设置JAVA_HOME。
  3. 如果你依赖Java buildpack为你的dist-zip风格的应用程序创建启动命令,那么它将做正确的事情&#34;和add the JAVA_HOME environment variable以及启动命令的正确路径。
  4. 如果您需要创建自定义启动命令,则您有责任正确设置JAVA_HOME。
  5. 如果您cf ssh进入由Java buildpack启动的应用程序,则您有责任设置JAVA_HOME。