[英]Remote debugging of Bluemix CF Java buildpack application
I have a standalone java application deployed on IBM Bluemix as Cloud Foundry Java buildpack. 我有一个作为Cloud Foundry Java buildpack部署在IBM Bluemix上的独立Java应用程序。
Is there a way to perform remote debugging on it in Eclipse?I could find only docs for remote debugging of Java Liberty buildpack applications. 是否可以在Eclipse中对其执行远程调试?我只能找到用于Java Liberty buildpack应用程序的远程调试的文档。
The socket listen way mentioned in the other answer is certainly convenient, but expects you to have a public IP assigned to your debug machine(or you have to configure some port forwarding on your router). 在另一个答案中提到的套接字侦听方式当然很方便,但是希望您将一个公共IP分配给调试机(或者必须在路由器上配置一些端口转发)。 This might not always be possible. 这可能并不总是可能的。
So the another way to do it is enable debugging on your Java app and use ssh port forwarding to connect to the app instance. 因此,另一种方法是在Java应用程序上启用调试,并使用ssh端口转发连接到应用程序实例。 Following are the steps 以下是步骤
JBP_CONFIG_DEBUG
with value {enabled: true}
and restarting the application. 通过将环境变量JBP_CONFIG_DEBUG
设置为值{enabled: true}
并重新启动应用程序来启用Java调试。 Set up the SSH tunnel for the debug framework via JDWP 通过JDWP为调试框架设置SSH隧道
cf ssh -N -T -L 8000:localhost:8000 <APP_NAME>
After the ssh tunnel is opened, you use the Socket Attach debug type from eclipse on localhost:8000
打开ssh隧道后,您可以在localhost:8000
上使用来自eclipse的套接字附加调试类型
Prerequisites before cf ssh
: cf api
, cf login
, cf target
cf ssh
之前的先决条件: cf api
, cf login
, cf target
There are some instructions in the Java buildpack documentation at https://docs.cloudfoundry.org/buildpacks/java/java-tips.html#debugging Java buildpack文档中有一些说明, 网址为https://docs.cloudfoundry.org/buildpacks/java/java-tips.html#debugging
The debugger should now be running. 调试器现在应该正在运行。 If you switch to the Debug perspective, you should see your application listed in the Debug panel and it should say Waiting for vm to connect at port
. 如果切换到“调试”透视图,则应在“调试”面板中看到您的应用程序,并且应显示“ Waiting for vm to connect at port
。
Next, push your application to Cloud Foundry and instruct Cloud Foundry to connect to the debugger running on your local machine using the following instructions: 接下来,使用以下说明将应用程序推送到Cloud Foundry并指示Cloud Foundry连接到在本地计算机上运行的调试器:
-agentlib:jdwp=transport=dt_socket,address=YOUR-IP-ADDRESS:YOUR-PORT
. 将远程调试器配置添加到JAVA_OPTS变量: -agentlib:jdwp=transport=dt_socket,address=YOUR-IP-ADDRESS:YOUR-PORT
。 Upon completion, you should see that your application has started and is now connected to the debugger running in your IDE. 完成后,您应该看到您的应用程序已启动,并且现在已连接到在IDE中运行的调试器。 You can now add breakpoints and interrogate the application just as you would if it were running locally. 现在,您可以添加断点并查询应用程序,就像在本地运行该应用程序一样。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.