playframework / play1

Play framework
https://www.playframework.com/documentation/1.4.x/home
Other
1.58k stars 684 forks source link

Play Java 11 JDWP support #1356

Open danrods opened 3 years ago

danrods commented 3 years ago

Are you looking for help?

This is an issue when with the new updated versions of play 1.5.x that allows support for Java 11. The code itself can run on Java 11 but there's no support from the runner for JDWP

Play Version (1.5.x / etc)

v 1.5.3

Operating System (Ubuntu 15.10 / MacOS 10.10 / Windows 10)

Docker image openjdk:11-jre-slim

Linux 8a5a886fc0d3 5.10.25-linuxkit #1 SMP Tue Mar 23 09:27:39 UTC 2021 x86_64 GNU/Linux

JDK (Oracle 1.8.0_72, OpenJDK 1.8.x, Azul Zing)

openjdk version "11.0.11" 2021-04-20
OpenJDK Runtime Environment 18.9 (build 11.0.11+9)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.11+9, mixed mode, sharing)

Expected Behavior

Please describe the expected behavior of the issue, starting from the first action.

  1. WHEN invoking play run in a dev environment
  2. AND the java_version is one of the supported versions in Play 1.5.3 ( i.e java version 9, 10, 11)
  3. THEN the new command line option for JDWP since Java 9 should be used (i.e -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=127.0.0.1:8000 )

Actual Behavior

  1. When attaching a debugger on port 8000 in dev mode the connection closes immediately
  2. When attempting to add the new argument for JDWP since java 9: i.e play run --%dev -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=127.0.0.1:8000

Play fails to start with the error

ERROR:   Cannot load this JVM TI agent twice, check your java command line for duplicate jdwp options.
                Error occurred during initialization of VM
                agent library failed to init: jdwp
  1. There is no way to remove the redundant JDWP options while running in dev mode, because of the following logic in the python runner https://github.com/playframework/play1/blob/1.5.3/framework/pym/play/application.py#L308

Potential Fix

On line https://github.com/playframework/play1/blob/1.5.3/framework/pym/play/application.py#L305

  if application_mode == 'dev':
      self.check_jpda()
      java_args.append('-Xdebug')
      if javaVersion.startswith("9") or javaVersion.startswith("10") or javaVersion.startswith("11"):
         java_args.append('-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:%s' % self.jpda_port)
     else
         java_args.append('-Xrunjdwp:transport=dt_socket,address=%s,server=y,suspend=n' % self.jpda_port)
     java_args.append('-Dplay.debug=yes')

Thanks for the help in advance for any workarounds or fixes that come from this. I'm ok to Fork and open a PR if warranted

cies commented 3 years ago

Possibly a dupe of (and/or fix for) #1331

danrods commented 10 months ago

@cies - I take it this was fixed in v1.7.0 alongside #1331 ?