Some notes on modularity in PlayFramework2

PlayFramework2 met lots of disapointments from frist release fans. The Internets is full of questions "How to do that I did it in Play 1". People found groovy templates better than Scalate, Jobs more intuitive than Akka and sbt is quite performance eating and upredictable in comparison to previous play python console. Otherwise second version bring really new level of technology that can be felt only after you start to do things in Scala, CoffeScript etc .. Static typing and functional nature is fantastic and overall technology expression brings you very close to things you remember from ruby, python and even one head higher.

Ebean ORM

The most disapointing things starts when you try to deal with modular application, many things that worked for version 1 became strange here. Ebean is the new ORM thar brings you power of SQL aware query constructing. It has some problems when you start is modular:

from time to time is will bring you "It has not been enhanced but it's superClass" error, folks says adding ebeanEnabled := true option as settings param in Build.scala sould helps, but looks like not always, whant helped me is to change place of model pattern enumeration for ebean, so if you had:


just try to change is to:


and re-run recompile everything. Funny, yes. Two commands you should remember as Ctrl+Alt+Del are: reload and clean.

Module Namespaces

to create new module stub you can you play new command but folder structure has to be reorganised:

move controllers, models and views and other app contents inside namespace that can be the either name of our module or java way domain notation, sothat you should have your controller definition in:


but dynamic assets must be placed on the same place in order to be compiled, e.g.:


Bit confusing and probably can be changed with Build.scala definitions. NB: your module routes definition must be kept as it is in main module, so no namespaces here, byt the way, routes requires a special talk:

Reverse Routes

The second thing is Reverse routing. You must have route entry in module and in main app both in order to get routes working, the same  entry. This is probably the payment for fast and compiled routes. One more thing: to get route for your module in view use the following convention:


That's all I have for today, except captcha problem I described and article before and file upload and storage policy change (files are stored implicitly to fs without blob cruntch in Play 1 you can found info in official howtos).

Partly ported this site to PlayFramework2 I'm still optimistic as it brings more good things than problems to development process.