Search code examples
windows-servicesplayframework-2.0windows-server-2012

Play Framework 2 Stage Task on Windows, "The input line is too long"


I'm trying to Play 2 application on Windows Server Server 2012 using the "stage" task, with the goal of wrapping this up in a service so the application will automatically run when the server gets restarted. However, when running the app I get the following message:

The input line is too long.
The syntax of the command is incorrect.

This is because Windows has a limit of around 8000 characters for command line instructions but it seems like the Play stage command is exceeding this by passing the classpath as an argument.

Copying the "stage" folder to c:\ might fix the issue (as it'll reduce the size of the classpath) but I was hoping there would be a more elegant solution.

Has anyone found a way around this? Alternatively, do people have any suggestions for running a Play application on Windows so that it will automatically run when the server is restarted.

Thanks.


Solution

  • UPDATE: sbt native packager now comes with a number of built in solutions to this, see NieMaszNic's answer below.

    This is a known issue, being tracked in the SBT native packager (which generates the start script) here:

    https://github.com/sbt/sbt-native-packager/issues/72

    My recommendation to work around this issue would be to write your own start batch script that uses a wildcard classpath matcher. You can put this script in the dist directory in your Play project, and it will end up being packaged up with your application. That script might look like this:

    java %1 -cp "./lib/*;" play.core.server.NettyServer .
    

    Note that if you use a wildcard classpath matcher, you can no longer rely on classpath ordering to be the same as in dev mode. You shouldn't rely on classpath ordering anyway, but people inevitably do.