Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I deploy Play! framework application standalone (no war) and not include the source in app folder?

I am using play-1.2.3.

I have performed the following steps:

  • set to production in application.conf
  • play precompile myApp
  • remove app directory from myApp
  • play run myApp -Dprecompiled=true

The first request to myApp results in a TemplateNotFoundException. Are the steps correct?

I can't deploy source due to company restrictions. I could look into deploying using Jetty if the above will not work.

Update
Stacktrace is:

12:27:53,932 INFO  ~ Starting C:\play-1.2.3\samples-and-tests\chat
12:27:54,008 INFO  ~ Application is precompiled
12:27:54,553 INFO  ~ Application 'chat' is now started !
12:27:54,647 INFO  ~ Listening for HTTP on port 9000 ...
12:28:02,466 ERROR ~

@686d104bp
Internal Server Error (500) for request GET /

Execution exception
NullPointerException occured : null

play.exceptions.JavaExecutionException
    at play.mvc.ActionInvoker.invoke(ActionInvoker.java:229)
    at Invocation.HTTP Request(Play!)
Caused by: java.lang.NullPointerException
    at play.exceptions.TemplateNotFoundException.<init>(TemplateNotFoundException.java:25)
    at play.mvc.Controller.renderTemplate(Controller.java:666)
    at play.mvc.Controller.renderTemplate(Controller.java:639)
    at play.mvc.Controller.render(Controller.java:694)
    at controllers.Application.index(Application.java:14)
    at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:546)

    at play.mvc.ActionInvoker.invoke(ActionInvoker.java:500)
    at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:476)

    at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:471)

    at play.mvc.ActionInvoker.invoke(ActionInvoker.java:159)
    ... 1 more
like image 665
tom eustace Avatar asked Oct 21 '11 09:10

tom eustace


2 Answers

This has been reported on lighthouse as case #806 https://play.lighthouseapp.com/projects/57987-play-framework/tickets/806. I have done some investigation and found that, in 1.2.3, it is not possible to run in precompiled mode without the template source being present. I've made more extensive comments about the problem on case #806.

I've also implemented a fix and pushed it to my fork of play at [email protected]:WiredThing/play.git and I've issued a pull request to playframework in case they want to pull it in.

But, to re-iterate, in the stock play release it is possible to remove the java source in precompiled mode, but the templates sources must be present, even though it loads the bytecode from the precompiled files.

like image 148
DougC Avatar answered Oct 22 '22 21:10

DougC


It's a bit of a hack, and I have not verified it beyond a quick test with one template, but one workaround appears to be deleting the contents of your templates so that the files still technically exist (so Play is happy), but your templates do not actually get exposed.

like image 43
sixbitproxywax Avatar answered Oct 22 '22 23:10

sixbitproxywax