Continuous build Play Framework application

Hi,

I’m trying to run my Play Framework application in continuous build mode but I’m always getting the following error:

`FATAL ERROR in native method: JDWP No transports initialized, jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197)
ERROR: transport error 202: bind failed: Address already in use
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized […/…/…/src/share/back/debugInit.c:741] Could not write standard input into: Gradle Play Worker 3.
java.io.IOException: The pipe is being closed
at java.io.FileOutputStream.writeBytes(Native Method)
at java.io.FileOutputStream.write(FileOutputStream.java:318)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
at org.gradle.process.internal.streams.ExecOutputHandleRunner.run(ExecOutputHandleRunner.java:56)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
:moduleTest:runPlayBinary FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:moduleTest:runPlayBinary’.

Process ‘Gradle Play Worker 3’ finished with non-zero exit value 1

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED`

I have the following configuration in my task:

tasks.withType(PlayRun) { httpPort = 9010 forkOptions.jvmArgs = ['-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9021'] }

And I’m using the play plugin and Gradle 2.12

plugins { id 'play' }

Has anyone went through the same error?

Regards,
Joao

Do you have multiple PlayRun tasks running at the same time?

Initially yes, I had my custom task within the allprojects{…} configuration.

So, now I have the following in my root project:

plugins { id 'play' } tasks.withType(PlayRun) { httpPort = 9010 forkOptions.jvmArgs = ['-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9021'] } allprojects { ..... }

All my sub modules are also Play projects and I use the Play plugin, I had to set in each module the custom task to disable the PlayRun task.

tasks.withType(PlayRun) { enabled = false }

Without this, a Play instance would be started in the default port (9000).

Is this the correct way to setup ?

I also have tried the play/multiproject sample in gradle distribution and running it with continuous build does not work.

Regards

I assume you were trying to run ./gradlew playRun? That tries to run the PlayRun task in all of the subprojects and since you’re setting the port to be the same for all projects, you’ll get conflicts.

If you only need to run the application in one subproject, you can run ./gradlew subprojectName:playRun. If you’re just running playRun for the root project, you’d use :playRun (: is the root project name).

If you need to start all of the Play applications up at the same time, you can use ./gradlew playRun, but you’ll need to assign unique ports for every project.

Setting tasks.withType(PlayRun) { enabled = false } for all subprojects is fine if it never makes sense to start them up as separate apps.

The multi-project sample doesn’t assign unique ports (continuous build didn’t exist when it was written), so you cannot start all of the subprojects up at once.

Your assumption is correct.

By lack of knowledge, I did not know that the task is performed for all subprojects. As this is a multi-module project, I thought the task would only be run in the root project.

All my subprojects will never start up as separate apps, it will always run in the context of the root project application. Subprojects will work as individuals modules that will be bound in the same application instance.

In this case, I assume that using tasks.withType(PlayRun) { enabled = false } is the appropriate approach to solve my issue.

If relevant, I will be glad to contribute with a working sample.

Thanks for your explanation!