Launching a Play app on Windows
This page explains how to fix a common issue encountered while running a Play app in production on Windows.
Distribution
To build a package for your Play framework application, just run:
sbt dist
This will create a yourapp-1.0-SNAPSHOT.zip
package in the target folder.
The zip contains a bin/
folder with some launchers.
The Linux one is working well out of the box, but usually the Windows launcher (yourapp.bat
) cannot be run directly due to some limitation
in the length of the classpath line.
Fixing input line length issue
The generated .bat launcher contains a line setting the classpath which usually exceeds the maximum length allowed by Windows. If you run the .bat directly you may be getting the error:
The input line is too long.
The syntax of the command is incorrect.
Luckily there is an easy fix for that: open the .bat file, and find the APP_CLASSPATH definition (around line 43).
set "APP_CLASSPATH=%APP_LIB_DIR%\..\conf\;%APP_LIB_DIR%\holon-web.holon-web-1.0-SNAPSHOT-sans-externalized.jar;%APP_LIB_DIR%\org.scala-lang.scala-library-2.13.15.jar;%APP_LIB_DIR%\com.typesafe.play.twirl-api_2.13-1.6.8.jar;%APP_LIB_DIR%\com.typesafe.play.play-server_2.13-2.9.5.jar;%APP_LIB_DIR%\com.typesafe.play.play-akka-http-server_2.13-2.9.5.jar;%APP_LIB_DIR%\com.typesafe.play.play-logback_2.13-2.9.5.jar;%APP_LIB_DIR%\com.typesafe.play.play-filters-helpers_2.13-2.9.5.jar;%APP_LIB_DIR%\com.typesafe.play.play-java-forms_2.13-2.9.5.jar;%APP_LIB_DIR%\com.typesafe.play.play-caffeine-cache_2.13-2.9.5.jar;%APP_LIB_DIR%\com.typesafe.play.play-guice_2.13-2.9.5.jar; ... and a lot more "
The solution is to replace this extensive definition by a single expression:
set "APP_CLASSPATH=%APP_LIB_DIR%\..\conf\;%APP_LIB_DIR%\*"
Then running the .bat file should work flawlessly.
Conclusion
In this article we saw how to fix a common issue while running the Windows launcher for a Play framework application.
comments powered by Disqus