Bluemix /如何使用嵌入式Web服务部署可执行的独立Java应用程序?

时间:2015-12-22 10:29:16

标签: java executable ibm-cloud

我想在Bluemix下部署和运行一个独立的Java应用程序,该应用程序已在IBM Java 7 JVM下本地配置和测试。在本地,可执行过程在使用命令开始时工作正常:

java -jar myjar.jar

Java jarfile已经包含由MAVEN构建构建的默认META-INF / MANIFEST.MF文件中指定的Class-Path和Main-Class。

使用以下命令部署映像:

cf push myapp1 -p ./target/ibm-myapp-1.0-SNAPSHOT-jar-with-dependencies.jar -b java_buildpack

推送阶段的Bluemix Cloud Foundry为OpenJDK版本8安装运行时。在Bluemix控制台,我得到以下日志消息,没有任何进一步的调试细节,请参阅log ::

2015-12-21T15:07:46.571-0200
[DEA/169]
err
Instance (index 0) failed to start accepting connections
2015-12-21T15:07:46.601-0200
[API/0]
out
App instance exited with guid e69f8f4e-86ed-46d6-9ba2-2d542854c278 payload: 
{"cc_partition"=>"default", "droplet"=>"e69f8f4e-86ed-46d6-9ba2-2d542854c278", 
"version"=>"43d973ae-f849-4a9b-9f70-182e049759de", 
"instance"=>"dbf65f84413f4a4da19f425d726ba4d9", 
"index"=>0, "reason"=>"CRASHED", 
"exit_status"=>127, "exit_description"=>"failed to accept connections within health check timeout",
"crash_timestamp"=>1450717666}

如何在Java环境中调试和圈出根错误或如何在应用程序代码中找到错误?

通过编辑,添加并行命令获取的完整日志:cf logs oauth2java --recent

日志:

2015-12-22T15:37:34.10-0200 [DEA/126]    OUT Removing crash for app with id e69f8f4e-86ed-46d6-9ba2-2d542854c278
2015-12-22T15:37:34.10-0200 [DEA/126]    OUT Stopping app instance (index 0) with guid e69f8f4e-86ed-46d6-9ba2-2d542854c278
2015-12-22T15:37:34.10-0200 [DEA/126]    OUT Stopped app instance (index 0) with guid e69f8f4e-86ed-46d6-9ba2-2d542854c278
2015-12-22T15:42:09.46-0200 [DEA/62]     OUT Starting app instance (index 0) with guid e69f8f4e-86ed-46d6-9ba2-2d542854c278
2015-12-22T15:42:22.54-0200 [API/3]      OUT App instance exited with guid e69f8f4e-86ed-46d6-9ba2-2d542854c278 payload: {"cc_partition"=>"default", "droplet"=>"e69f8f4e-86ed-46d6-9ba2-2d542854c278", "version"=>"148362a7-22a0-4dee-ad3d-e3387329af9b", "instance"=>"4ff542a202154ebca8a70c3be763782f", "index"=>0, "reason"=>"CRASHED", "exit_status"=>127, "exit_description"=>"app instance exited", "crash_timestamp"=>1450806142}
2015-12-22T15:42:22.55-0200 [API/2]      OUT App instance exited with guid e69f8f4e-86ed-46d6-9ba2-2d542854c278 payload: {"cc_partition"=>"default", "droplet"=>"e69f8f4e-86ed-46d6-9ba2-2d542854c278", "version"=>"148362a7-22a0-4dee-ad3d-e3387329af9b", "instance"=>"4ff542a202154ebca8a70c3be763782f", "index"=>0, "reason"=>"CRASHED", "exit_status"=>127, "exit_description"=>"failed to start", "crash_timestamp"=>1450806142}
2015-12-22T16:02:34.42-0200 [DEA/56]     OUT Removing crash for app with id e69f8f4e-86ed-46d6-9ba2-2d542854c278
2015-12-22T16:02:34.42-0200 [DEA/56]     OUT Stopping app instance (index 0) with guid e69f8f4e-86ed-46d6-9ba2-2d542854c278
2015-12-22T16:02:34.42-0200 [DEA/56]     OUT Stopped app instance (index 0) with guid e69f8f4e-86ed-46d6-9ba2-2d542854c278
2015-12-22T16:04:01.83-0200 [API/2]      OUT Updated app with guid e69f8f4e-86ed-46d6-9ba2-2d542854c278 ({"state"=>"STOPPED"})
2015-12-22T16:05:10.21-0200 [API/2]      OUT Updated app with guid e69f8f4e-86ed-46d6-9ba2-2d542854c278 ({"name"=>"myapp1", "memory"=>1024})
2015-12-22T16:13:29.85-0200 [API/0]      OUT Updated app with guid e69f8f4e-86ed-46d6-9ba2-2d542854c278 ({"name"=>"myapp1", "memory"=>1024})
2015-12-22T16:22:52.20-0200 [API/2]      OUT Updated app with guid e69f8f4e-86ed-46d6-9ba2-2d542854c278 ({"name"=>"myapp1", "memory"=>1024})
2015-12-22T16:27:34.21-0200 [DEA/38]     OUT Removing crash for app with id e69f8f4e-86ed-46d6-9ba2-2d542854c278
2015-12-22T16:27:34.21-0200 [DEA/38]     OUT Stopping app instance (index 0) with guid e69f8f4e-86ed-46d6-9ba2-2d542854c278
2015-12-22T16:27:34.21-0200 [DEA/38]     OUT Stopped app instance (index 0) with guid e69f8f4e-86ed-46d6-9ba2-2d542854c278
2015-12-22T16:31:08.81-0200 [API/5]      OUT Updated app with guid e69f8f4e-86ed-46d6-9ba2-2d542854c278 ({"name"=>"myapp1", "memory"=>1024})
2015-12-22T16:32:38.72-0200 [DEA/0]      OUT Got staging request for app with id e69f8f4e-86ed-46d6-9ba2-2d542854c278
[claudef@oc2615188332 ~]$ cf logs myapp1 --recent
Connected, dumping recent logs for app myapp1 in org tester@br.red.com / space dev as tester@br.red.com...

2015-12-22T15:12:37.41-0200 [DEA/21]     OUT Stopping app instance (index 0) with guid e69f8f4e-86ed-46d6-9ba2-2d542854c278
2015-12-22T15:17:09.40-0200 [DEA/110]    OUT Starting app instance (index 0) with guid e69f8f4e-86ed-46d6-9ba2-2d542854c278
2015-12-22T15:37:34.10-0200 [DEA/126]    OUT Removing crash for app with id e69f8f4e-86ed-46d6-9ba2-2d542854c278
2015-12-22T15:37:34.10-0200 [DEA/126]    OUT Stopping app instance (index 0) with guid e69f8f4e-86ed-46d6-9ba2-2d542854c278
2015-12-22T15:37:34.10-0200 [DEA/126]    OUT Stopped app instance (index 0) with guid e69f8f4e-86ed-46d6-9ba2-2d542854c278
2015-12-22T15:42:09.46-0200 [DEA/62]     OUT Starting app instance (index 0) with guid e69f8f4e-86ed-46d6-9ba2-2d542854c278
2015-12-22T15:42:22.54-0200 [API/3]      OUT App instance exited with guid e69f8f4e-86ed-46d6-9ba2-2d542854c278 payload: {"cc_partition"=>"default", "droplet"=>"e69f8f4e-86ed-46d6-9ba2-2d542854c278", "version"=>"148362a7-22a0-4dee-ad3d-e3387329af9b", "instance"=>"4ff542a202154ebca8a70c3be763782f", "index"=>0, "reason"=>"CRASHED", "exit_status"=>127, "exit_description"=>"app instance exited", "crash_timestamp"=>1450806142}
2015-12-22T15:42:22.55-0200 [API/2]      OUT App instance exited with guid e69f8f4e-86ed-46d6-9ba2-2d542854c278 payload: {"cc_partition"=>"default", "droplet"=>"e69f8f4e-86ed-46d6-9ba2-2d542854c278", "version"=>"148362a7-22a0-4dee-ad3d-e3387329af9b", "instance"=>"4ff542a202154ebca8a70c3be763782f", "index"=>0, "reason"=>"CRASHED", "exit_status"=>127, "exit_description"=>"failed to start", "crash_timestamp"=>1450806142}
2015-12-22T16:02:34.42-0200 [DEA/56]     OUT Removing crash for app with id e69f8f4e-86ed-46d6-9ba2-2d542854c278
2015-12-22T16:02:34.42-0200 [DEA/56]     OUT Stopping app instance (index 0) with guid e69f8f4e-86ed-46d6-9ba2-2d542854c278
2015-12-22T16:02:34.42-0200 [DEA/56]     OUT Stopped app instance (index 0) with guid e69f8f4e-86ed-46d6-9ba2-2d542854c278
2015-12-22T16:04:01.83-0200 [API/2]      OUT Updated app with guid e69f8f4e-86ed-46d6-9ba2-2d542854c278 ({"state"=>"STOPPED"})
2015-12-22T16:05:10.21-0200 [API/2]      OUT Updated app with guid e69f8f4e-86ed-46d6-9ba2-2d542854c278 ({"name"=>"myapp1", "memory"=>1024})
2015-12-22T16:13:29.85-0200 [API/0]      OUT Updated app with guid e69f8f4e-86ed-46d6-9ba2-2d542854c278 ({"name"=>"myapp1", "memory"=>1024})
2015-12-22T16:22:52.20-0200 [API/2]      OUT Updated app with guid e69f8f4e-86ed-46d6-9ba2-2d542854c278 ({"name"=>"myapp1", "memory"=>1024})
2015-12-22T16:27:34.21-0200 [DEA/38]     OUT Removing crash for app with id e69f8f4e-86ed-46d6-9ba2-2d542854c278
2015-12-22T16:27:34.21-0200 [DEA/38]     OUT Stopping app instance (index 0) with guid e69f8f4e-86ed-46d6-9ba2-2d542854c278
2015-12-22T16:27:34.21-0200 [DEA/38]     OUT Stopped app instance (index 0) with guid e69f8f4e-86ed-46d6-9ba2-2d542854c278
2015-12-22T16:31:08.81-0200 [API/5]      OUT Updated app with guid e69f8f4e-86ed-46d6-9ba2-2d542854c278 ({"name"=>"myapp1", "memory"=>1024})
2015-12-22T16:32:38.72-0200 [DEA/0]      OUT Got staging request for app with id e69f8f4e-86ed-46d6-9ba2-2d542854c278
2015-12-22T16:32:45.68-0200 [API/1]      OUT Updated app with guid e69f8f4e-86ed-46d6-9ba2-2d542854c278 ({"state"=>"STARTED"})
2015-12-22T16:32:46.53-0200 [STG/0]      OUT -----> Downloaded app package (4.9M)
2015-12-22T16:32:47.01-0200 [STG/0]      OUT -----> Downloaded app buildpack cache (44M)
2015-12-22T16:32:50.12-0200 [STG/0]      OUT -----> Java Buildpack Version: v3.3 | https://github.com/cloudfoundry/java-buildpack.git#378f420
2015-12-22T16:32:50.48-0200 [STG/0]      OUT -----> Downloading Open Jdk JRE 1.8.0_65 from https://download.run.pivotal.io/openjdk/trusty/x86_64/openjdk-1.8.0_65.tar.gz (found in cache)
2015-12-22T16:32:51.66-0200 [STG/0]      OUT        Expanding Open Jdk JRE to .java-buildpack/open_jdk_jre (1.1s)
2015-12-22T16:32:51.81-0200 [STG/0]      OUT -----> 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)
2015-12-22T16:32:51.87-0200 [STG/0]      OUT        Memory Settings: -Xss1M -Xmx768M -XX:MaxMetaspaceSize=104857K -Xms768M -XX:MetaspaceSize=104857K
2015-12-22T16:32:53.53-0200 [STG/0]      ERR 

2015-12-22T16:33:01.37-0200 [STG/0]      OUT -----> Uploading droplet (48M)
2015-12-22T16:33:13.11-0200 [DEA/0]      OUT Starting app instance (index 0) with guid e69f8f4e-86ed-46d6-9ba2-2d542854c278
2015-12-22T16:33:25.33-0200 [API/1]      OUT App instance exited with guid e69f8f4e-86ed-46d6-9ba2-2d542854c278 payload: {"cc_partition"=>"default", "droplet"=>"e69f8f4e-86ed-46d6-9ba2-2d542854c278", "version"=>"fe1737f1-802c-4c53-acbc-331d78181fc8", "instance"=>"361273f4bc7643ac9e0c600ea6369353", "index"=>0, "reason"=>"CRASHED", "exit_status"=>127, "exit_description"=>"failed to start", "crash_timestamp"=>1450809205}
2015-12-22T16:33:25.36-0200 [API/0]      OUT App instance exited with guid e69f8f4e-86ed-46d6-9ba2-2d542854c278 payload: {"cc_partition"=>"default", "droplet"=>"e69f8f4e-86ed-46d6-9ba2-2d542854c278", "version"=>"fe1737f1-802c-4c53-acbc-331d78181fc8", "instance"=>"361273f4bc7643ac9e0c600ea6369353", "index"=>0, "reason"=>"CRASHED", "exit_status"=>127, "exit_description"=>"app instance exited", "crash_timestamp"=>1450809205}
2015-12-22T16:34:54.60-0200 [DEA/85]     OUT Starting app instance (index 0) with guid e69f8f4e-86ed-46d6-9ba2-2d542854c278
2015-12-22T16:35:09.41-0200 [API/7]      OUT App instance exited with guid e69f8f4e-86ed-46d6-9ba2-2d542854c278 payload: {"cc_partition"=>"default", "droplet"=>"e69f8f4e-86ed-46d6-9ba2-2d542854c278", "version"=>"fe1737f1-802c-4c53-acbc-331d78181fc8", "instance"=>"4fd310e9f1724f149a14ab4a63f49a9c", "index"=>0, "reason"=>"CRASHED", "exit_status"=>127, "exit_description"=>"app instance exited", "crash_timestamp"=>1450809309}
2015-12-22T16:35:54.97-0200 [DEA/136]    OUT Starting app instance (index 0) with guid e69f8f4e-86ed-46d6-9ba2-2d542854c278
2015-12-22T16:36:03.95-0200 [API/7]      OUT App instance exited with guid e69f8f4e-86ed-46d6-9ba2-2d542854c278 payload: {"cc_partition"=>"default", "droplet"=>"e69f8f4e-86ed-46d6-9ba2-2d542854c278", "version"=>"fe1737f1-802c-4c53-acbc-331d78181fc8", "instance"=>"b2f3614f1fc34193aada658b24d9985b", "index"=>0, "reason"=>"CRASHED", "exit_status"=>127, "exit_description"=>"app instance exited", "crash_timestamp"=>1450809363}
2015-12-22T16:36:54.54-0200 [DEA/67]     OUT Starting app instance (index 0) with guid e69f8f4e-86ed-46d6-9ba2-2d542854c278

控制台消息:

cf push myapp1 -p ./target/red-oauth-1.0-SNAPSHOT-jar-with-dependencies.jar -m 1G  --no-route 
Updating app myapp1 in org tester@br.red.com / space dev as tester@br.red.com...
OK

App myapp1 is a worker, skipping route creation
Uploading myapp1...
Uploading app files from: ./target/red-oauth-1.0-SNAPSHOT-jar-with-dependencies.jar
Uploading 10.3M, 3584 files
Done uploading               
OK

Starting app myapp1 in org tester@br.red.com / space dev as tester@br.red.com...
-----> Downloaded app package (4.9M)
-----> Downloaded app buildpack cache (44M)
-----> Java Buildpack Version: v3.3 | https://github.com/cloudfoundry/java-buildpack.git#378f420
-----> Downloading Open Jdk JRE 1.8.0_65 from https://download.run.pivotal.io/openjdk/trusty/x86_64/openjdk-1.8.0_65.tar.gz (found in cache)
       Expanding Open Jdk JRE to .java-buildpack/open_jdk_jre (1.1s)
-----> 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: -Xss1M -Xmx768M -XX:MaxMetaspaceSize=104857K -Xms768M -XX:MetaspaceSize=104857K

-----> Uploading droplet (48M)

0 of 1 instances running, 1 starting
0 of 1 instances running, 1 down
0 of 1 instances running, 1 down
0 of 1 instances running, 1 down
0 of 1 instances running, 1 down
0 of 1 instances running, 1 down
0 of 1 instances running, 1 down
0 of 1 instances running, 1 down
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 down
0 of 1 instances running, 1 down
0 of 1 instances running, 1 down
0 of 1 instances running, 1 down
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 down
0 of 1 instances running, 1 down
0 of 1 instances running, 1 down
0 of 1 instances running, 1 failing
FAILED
Start unsuccessful

TIP: use 'cf logs myapp1 --recent' for more information

按照我在此处找到的提示[https://support.run.pivotal.io/entries/80755985-How-do-I-size-my-Java-or-JVM-based-applications-] 我在添加到push命令的cloud foundry -m(memory)参数中做了几处调整,该参数自动配置Java堆大小参数(-Xmx)和其他内存相关参数。目前的设置是-m 3G。

日志也引发了关于" CRASHED"退出状态为127,这可能指向端口级别的问题。我尝试读取环境变量PORT,VCAP_PORT和VCAP_APP_PORT以识别活动端口号。他们都没有改变错误代码。

此外,我已将OpenJDK JVM降级到1.7版,以使用我本地构建环境的相同Java版本。

请参阅下面的日志,到目前为止,添加了最新更改后,错误情况没有变化:

2015-12-23T08:51:52.09-0200 [STG/0]      OUT        Memory Settings: -Xmx2304M -Xms2304M -XX:PermSize=314572K -XX:MaxPermSize=314572K -Xss1M
2015-12-23T08:51:53.71-0200 [STG/0]      ERR 
2015-12-23T08:52:00.35-0200 [STG/71]     OUT -----> Uploading droplet (39M)
2015-12-23T08:52:10.01-0200 [DEA/71]     OUT Starting app instance (index 0) with guid e69f8f4e-86ed-46d6-9ba2-2d542854c278
2015-12-23T08:52:17.82-0200 [DEA/71]     ERR Instance (index 0) failed to start accepting connections
2015-12-23T08:52:17.84-0200 [API/7]      OUT App instance exited with    
guid e69f8f4e-86ed-46d6-9ba2-2d542854c278 payload: {"cc_partition"=>"default", "droplet"=>"e69f8f4e-86ed-46d6-9ba2-2d542854c278", "version"=>"6935bc6a-fe72-452b-866c-ec72d1edd3e4", "instance"=>"aef5cf7846e645aca1257331f7aa7b7e", "index"=>0, "reason"=>"CRASHED", "exit_status"=>127, "exit_description"=>"failed to accept connections within health check timeout", "crash_timestamp"=>1450867937}

0 个答案:

没有答案