简体   繁体   English

Cloud Foundry Java buildpack-Java:找不到命令

[英]Cloud Foundry java buildpack - java: command not found

New to cloud foundry, using the java buildpack to push a zip distribution of a java app. 云铸造的新手,使用java buildpack推送Java应用程序的zip发行版。 It detects the start script correctly, but when the start script gets to the point where it needs to start up the jvm, I get this error: 它正确地检测到启动脚本,但是当启动脚本到达需要启动jvm的地步时,出现以下错误:

bash: java: command not found bash:java:找不到命令

Apparently 'java' is not on the shell's path during execution of the script, and I'm not finding a JAVA_HOME definition anywhere. 显然,在执行脚本的过程中,“ java”不在外壳程序的路径上,而且我在任何地方都找不到JAVA_HOME定义。

What is the path to use for starting java apps? 用于启动Java应用程序的路径是什么? Where is it documented? 它记录在哪里?

FALSE ALARM 虚假警报

Many thanks to @DanielMikusa for pointing out that JAVA_HOME is indeed set, even in the pretty old version of the buildpack that was in use. 非常感谢@DanielMikusa指出,即使在使用的很老的buildpack版本中,也确实设置了JAVA_HOME。 Nothing to see here. 这没东西看。

EDIT #1 编辑#1

I've been able to find out that when the start script launches there is a jre located in $PWD/.buildpack-java/oracle_jre . 我已经发现启动脚本启动时,在$PWD/.buildpack-java/oracle_jre有一个jre。 But, this can't be what I'm expected to use to specify for the path of JAVA_HOME , can it? 但是,这不是我期望用来为JAVA_HOME的路径指定的,可以吗? It seems like this location is entirely dependent on the java buildpack's current implementation. 看来此位置完全取决于java buildpack的当前实现。 It seems like either the jre's bin folder should be in the start script's process' path or that there should be an environment variable or other configuration established prior to running the launch script so I can use that value for finding the java executable. 看起来jre的bin文件夹应该在启动脚本的进程路径中,或者应该在运行启动脚本之前建立环境变量或其他配置,以便我可以使用该值查找java可执行文件。

EDIT #2 编辑#2

Below is the output during the cf push operation: 以下是cf push操作期间的输出:

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`

Writing up the comments above in case someone else comes across this question. 写出以上评论,以防其他人遇到此问题。

  1. We reviewed the full output of staging and the start up command generated by the Java buildpack. 我们回顾了暂存的全部输出以及Java buildpack生成的启动命令。
  2. We could see from the start command generated by the Java buildpack that it is the start commands responsibility to set JAVA_HOME. 从Java buildpack生成的启动命令可以看出,设置JAVA_HOME是启动命令的职责。
  3. If you rely on the Java buildpack to create the start command for your dist-zip style applications, it will "do the right thing" and add the JAVA_HOME environment variable with the correct path to the start command. 如果您依靠Java buildpack为dist-zip样式的应用程序创建启动命令,它将“做正确的事”,并向启动命令添加具有正确路径的JAVA_HOME环境变量
  4. If you need to create a custom start command, it is your responsibility to set JAVA_HOME correctly. 如果需要创建自定义的启动命令,则有责任正确设置JAVA_HOME。
  5. If you cf ssh into an application started by the Java buildpack, it is your responsibility to set JAVA_HOME. 如果将cf ssh到由Java buildpack启动的应用程序中,则设置JAVA_HOME是您的责任。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM