4

When running an elastic beanstalk java application (not tomcat), how can I enable remote debugging?

AWS documentation shows how it could be achieved for the app, by specifying the command that starts the java process.

But if I want to deploy the SAME app separately (for instance a dev and a prod deployment), and only want to enable remote debugging for dev, how can this be achieved?

Rob
  • 227
  • 2
  • 6

2 Answers2

5

This can be achieved by using the _JAVA_OPTIONS environment variable, as described here.

The name of the environment variable may vary by JVM vendor, but currently elastic beanstalk uses OpenJDK, which respects _JAVA_OPTIONS

[webapp@ip-XXXXXXX ~]$ java -version
openjdk version "1.8.0_131"
OpenJDK Runtime Environment (build 1.8.0_131-b11)
OpenJDK 64-Bit Server VM (build 25.131-b11, mixed mode)

You can set this environment variable only in the elastic beanstalk environment for which you wish to enable debugging. For example

_JAVA_OPTIONS=-Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=5001,suspend=n

Notes:

  • the port you select must be open in one of the security groups assigned to your instances in that elastic beanstalk environment configuration.
  • this works best if you are only running one instance in the elastic beanstalk, if you are running multiple instances then you won't know which instance to attach your debugger to.
Rob
  • 227
  • 2
  • 6
0

I think you can use aws tool plugins for Eclipse https://aws.amazon.com/eclipse/

enter image description here

Tick the box and save will allow user to remote debug.

Or change in AWS console > Elastic Beanstalk > Config > JVM options

enter image description here

Above is for JDK before JDK5

For JDK8: -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8787

sendon1982
  • 9,982
  • 61
  • 44