Do not reboot on view change


we have a frontend developer in our team who is in charge for our views. Because the twirl templates will be compiled to scala code in playframework (like the idea of typed templates!) the server reboots on every view change, even if only html has been changed.

So there is the question if there is any possibility to skip the reboot on view changes and use something like hot-code-replace like JRebel?

Thanks and best regards

We don’t have hot-code-replace using JRebel out-of-the-box.

The server reboot for every change because, as you said, the views are compiled. So, if you disable watching the views folder, then you will need to stop the process, and start it again to see the changes. Is that what you want? Maybe you will be better served by sbt ~run?


Hello marcospereira,

thanks for your reply and sry for my late one!

That is not what I meant. We already run the server in replace (~) mode, but compilation and startup time increases with a growing codebase so the frontend-developer is waiting a lot of time for only simple HTML changes, so a hot-code-replace for the views would be very helpful in a full-stack-team.
And sometimes (we do not know why) the whole codebase will be compiled after a view change which (and sometimes with the need of a hard server reboot). If this case happens, the recompile and reboot time increase so something between 5 and 8 Minutes.

Best regards

As far as I know, this is not possible out of the box, as view templates are compiled into functions, and yes, template being Scala based, does take a little bit more time to compile. I think you can use JRebel, came across a blog a while ago on this topic, although never tried myself.

In my experience, the recompile everything scenario happens when the routes are changed, have not seen this happen with view changes. Do you know what is triggering a complete recompile for you?

We have moved away from using Twirl for frontend, and started using things such as React for building views, much faster with change feedback loop (it will even refresh the browser for you, admittedly, can be annoy sometimes). This way, we keep Play for backend service, and save frontend folks from having to compile templates.

1 Like

Hey Patrick,

the scenario has no pattern. But in most cases the following exceptions happens:

Caused by: java.lang.IllegalArgumentException: requirement failed: Source file 'PROJECT_PATH/target/classes.bak/sbt1246272330747557348.class' does not exist.
[error] Caused by: java.lang.ClassNotFoundException: mypackage.MyClass

Switching to another frontend technology is - unfortunately - no scenario for us. But in generel I like the idea of the compiled templates which brings type safety to the view layer.

I will give JRebel a try and can post my experiences here.