Time to admit Play does not support on Windows Machine in Production

960 views
Skip to first unread message

Jay Park

unread,
Oct 31, 2012, 12:13:58 PM10/31/12
to play-fr...@googlegroups.com
Hi guys, 

I've been asking around for a long time. I've not found any correct documents or anyone who has succeeded the following. 

start -Dhttp.port=80 

This command simply does not work on Windows machines.  
Now is time to admit and change documents. Play CANNOT !!!

Cheers,
Jay


James Ward

unread,
Oct 31, 2012, 12:26:57 PM10/31/12
to play-fr...@googlegroups.com
That is the Unix start script. So it's not surprising that it doesn't
work on Windows.

Have you tried to just call java directly with the right params, like
the start script does?

-James
> --
> You received this message because you are subscribed to the Google
> Groups "play-framework" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/play-framework/-/qzRvgMHGjnkJ.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to play-framework
> +unsub...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/play-framework?hl=en.


James Mclemore

unread,
Oct 31, 2012, 4:38:57 PM10/31/12
to play-fr...@googlegroups.com
here is the contents of my start.bat file:
 
java %1 -DapplyEvolutions.default=true -Dhttp.port=80 -cp "./lib/*;" play.core.server.NettyServer .
 
hope this helps.

Jay Park

unread,
Oct 31, 2012, 10:02:15 PM10/31/12
to play-fr...@googlegroups.com
Not working, I called java directly with 80 port specified but had no luck. 

java  -Xms512M -Xmx1024M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256M -Dhttp.port=80 -Dfile.encoding=UTF8 -Dplay.version=""2.0.4"" -Dsbt.ivy.home="C:\dev\play-2.0.4\framework\..\repository" -Dplay.home="C:\dev\play-2.0.4\framework\." -Dsbt.boot.properties="file:///C:/dev/play-2.0.4/framework/sbt/sbt.boot.properties" -jar "C:\dev\play-2.0.4\framework\sbt\sbt-launch.jar" start

With "run" command, it works only with 9000. I know "run" is for only dev mode. 

Jay Park

unread,
Oct 31, 2012, 10:06:12 PM10/31/12
to play-fr...@googlegroups.com
@James Mclemore, I tried your script as well. 

java %1 -DapplyEvolutions.default=true -Dhttp.port=80 -cp "./lib/*;" play.core.server.NettyServer .

Can I ask how you manage all jars in the following path ("./lib/*;") ? 

Cheers,
Jay

James Roper

unread,
Oct 31, 2012, 10:53:12 PM10/31/12
to play-fr...@googlegroups.com
Maybe there is a bug, or maybe you've got something configured wrong, but you haven't given us any details, no logs, no error messages, anything, how are we supposed to help you?  This isn't a place for whinging, it's a place for getting help.

Jay Park

unread,
Oct 31, 2012, 11:07:38 PM10/31/12
to play-fr...@googlegroups.com
Hey James, You said it right ! I want to get some help and I'd like to help others after. 

I'd like to run play on default 80 port as stand alone. I ran the following command line. I can't see where it went wrong. 
Can you please advise me where I should look at or what logs I should take a look? 
Also, I realized that process ID is killed after a little while. 

play start java  -Xms512M -Xmx1024M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256M -Dhttp.port=80 -Dfile.encoding=UTF8 -Dplay.versi
""2.0.4"" -Dsbt.ivy.home="C:\dev\play-2.0.4\framework\..\repository" -Dplay.home="C:\dev\play-2.0.4\framework\." -Dsbt.boot.properties="file:///C:/dev/play-2
4/framework/sbt/sbt.boot.properties" -jar "C:\dev\play-2.0.4\framework\sbt\sbt-launch.jar" start
[info] Loading project definition from C:\dev\eslfish\project
[info] Set current project to eslfish (in build file:/C:/dev/eslfish/)

(Starting server. Type Ctrl+D to exit logs, the server will remain in background)

Play server process ID is 5120
This application is already running (Or delete C:\dev\eslfish\RUNNING_PID file).

Jay Park

unread,
Oct 31, 2012, 11:17:26 PM10/31/12
to play-fr...@googlegroups.com
Hi Christian, 

Are you running the your script from any IDE?

So, I ran your script in windows command line. 
However, %1 is not recognized.
Also, I wonder where this path ("./lib/*;") is located? I guess I need to copy all play related jars into a folder and point to it, right?

java -Dhttp.port=80 -Xmx64m %1 -cp "./lib/*;" play.core.server.NettyServer
Error: Could not find or load main class %1

Thanks!

James Roper

unread,
Oct 31, 2012, 11:28:17 PM10/31/12
to play-fr...@googlegroups.com
Ok, so your first problem is this:

Play server process ID is 5120
This application is already running (Or delete C:\dev\eslfish\RUNNING_PID file).

Either Play is already running, or something has gone wrong.  Check the Task manager to see if there are any java processes that might be from Play, and kill them.  If there are none, then delete C:\dev\eslfish\RUNNING_PID.

The second thing is, the best way to run Play in production is to produce an artifact by running "play clean compile dist".  This doesn't have to be run on the production machine, it will produce a zip file in the dist directory of your project.  You can then copy this zip file to your production server, unzip it, and it contains the lib folder with all the Jars that Christian talked about.

Let us know if you have any problems with that.

Cheers,

James

Khalid Alkassoum

unread,
Oct 31, 2012, 11:38:14 PM10/31/12
to play-fr...@googlegroups.com
in your project directory as usual-> play stage
then copy "target/stage" in your production dir, say "c:\myprodutiondir\target\stage"

create two files in "c:\myprodutiondir" run.bat and starter.bat.WINDOWS.KEEP

run.bat with this content

@echo off
echo this must be run in the parent directory of target
echo c:\myproductiondir\target\stage
echo cd c:\myproductiondir
echo run.bat
copy .\starter.bat.WINDOWS.KEEP .\target\starter.bat /Y
call target\starter.bat


and another file named starter.bat.WINDOWS.KEEP with this content

@echo off
java -cp  ".;%~dp0staged\*" -DapplyEvolutions.default=true -Dhttp.port=80 play.core.server.NettyServer "%~dp0.."

then cd in c:\myprodutiondir
c:\myprodutiondir>run.bat

Note this security warning
[info] application - JavaInvoker was created outside of JavaInvoker#init - this potentially could lead to initialization problems in production mode
but this is another subject ...

On next deployment, just replace stage content

Please tell us if this works for you

Jay Park

unread,
Oct 31, 2012, 11:54:28 PM10/31/12
to play-fr...@googlegroups.com
Thanks guys, I made it working with your help. 

Is there any way for me to contribute in updating the official documents?
I found so many email threads asking similar questions as mine but those email threads were ended without solving their problems. 

Here is what I did. 

1. play clean compile dist
2. upzip the zip file.
3. In the folder I unzipped, I ran the following command line. 
java -Dhttp.port=80 -Xmx64m -cp "lib/*;" play.core.server.NettyServer

4. it starts to run play app on default 80 port on Windows machine.

Many thanks to everyone!

James Ward

unread,
Nov 1, 2012, 1:07:03 AM11/1/12
to play-fr...@googlegroups.com
It would be great if you (or someone) can contribute a start.bat to the
"play dist" task. We need this but unfortunately most of us don't have
Windows machines to test on.

-James
> --
> You received this message because you are subscribed to the Google
> Groups "play-framework" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/play-framework/-/igptVajChXkJ.

Jay Park

unread,
Nov 1, 2012, 1:52:32 AM11/1/12
to play-fr...@googlegroups.com
There are some nice folks who made the following plugin to generate bat for Windows. 

Its an sbt plugin that adds additional tasks including creating start.bat file for windows.

However, there are no good documents to follow its instruction. So, it is not easy. 

Ok, after my time ticking project, I'll find a way to contribute. Thanks!

Jay

Ben McCann

unread,
Nov 2, 2012, 12:59:16 PM11/2/12
to play-fr...@googlegroups.com
Hi Khalid,

I'm also receiving the message "JavaInvoker was created outside of JavaInvoker#init - this potentially could lead to initialization problems in production mode".  Are you using the latest version of Play from GitHub or a released version.

Thanks,
Ben

peter hausel

unread,
Nov 2, 2012, 2:10:10 PM11/2/12
to play-fr...@googlegroups.com
Hi Ben,

That warning is a temporary issue, it will go away once the execution context change is finalized.

peter hausel

unread,
Nov 2, 2012, 2:12:58 PM11/2/12
to play-fr...@googlegroups.com
Hi Jay,

Play is not supporting windows in production, this fact is noted here: https://github.com/playframework/Play20/wiki/Production 

Cheers,
Peter

Ben McCann

unread,
Nov 2, 2012, 2:35:09 PM11/2/12
to play-fr...@googlegroups.com
Thanks for the update Peter.


--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To view this discussion on the web visit https://groups.google.com/d/msg/play-framework/-/CJyKkuRcy14J.

To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.
Message has been deleted

Jay Park

unread,
Nov 2, 2012, 10:22:38 PM11/2/12
to play-fr...@googlegroups.com
Thanks, Peter.

Note play is not supporting windows in production mode, therefore stage and start won't work under windows

So, it is true and sad news for Windows community or for those who have customers only having Windows hosting (my case)
Maybe, there are currently no commercial web sites with Play on Windows? Hope that is not true. 

I know there are workarounds like launching Play directly with Java command.
But then, Ctrl+D to close the Play console won't work. So, command prompt on Windows should be always on, which is not a good practice. 
Or you have to use Windows service wrapper or something. 

Or Windows users have to run Play on different ports than 80 and place a front-end web server as proxy. 

However, all I mentioned shows that Play is not Windows friendly. 

Jay

Ben McCann

unread,
Nov 3, 2012, 11:10:34 PM11/3/12
to play-fr...@googlegroups.com
What you're trying to do is bad practice to begin with. You shouldn't be running Play in production from the Play console regardless of whether you're using Windows or Linux. It is much better to do "play dist" and then invoke directly with the Java command. On Linux I use Supervisor to run in the background. On Windows you could run as a service or behind a proxy as you mentioned. We do these things on Linux as well. We run our app on Linux with a high port number so that administrator privileges are not required to launch it.
Reply all
Reply to author
Forward
0 new messages