Reading Time: < 1 minute
Play 2.3.0 application with ReactiveMongo – reactive, asynchronous and non-blocking Scala driver for MongoDB.
This is a classic CRUD application, backed by a MongoDB database. It demonstrates:
- Achieving, Futures to use more idiomatic error handling.
- Accessing a MongoDB database, using ReactiveMongo.
- Achieving, table pagination and sorting functionality.
- Replaced the embedded JS & CSS libraries with WebJars.
- Play and Scala-based template engine implementation
- Bootswatch-United with Twitter Bootstrap 3.1.1 to improve the look and feel of the application
Instructions :-
- The Github code for the project is at : playing-reactive-mongo
- Clone the project into local system
- To run the Play framework 2.3.0, you need JDK 6 or later
- Install Typesafe Activator if you do not have it already. You can get it from here: download
- Execute
activator clean compile
to build the product - Execute
activator run
to execute the product - playing-reactive-mongo should now be accessible at localhost:9000
References :-
This is the start, from next week onwards we would be working on this application to make it grow. We would look at how we can make it more functional, then we would be adding more modules to it together. If you have any changes then feel free to send in pull requests and we would do the merges 🙂 Stay tuned.
Reblogged this on Play!ng with Scala.
Reblogged this on Dinesh Ram Kali..
Hi I have this error -> http://pastebin.com/Z0Mhagnp
Hi Herkii,
Sorry for the inconvenience,
I have updated the code base with new play2-reactivemongo sonatype url because they have changed.
anand@anand-singh:~/projects/knoldus/playing-reactive-mongo$ ./activator clean compile
[info] Loading project definition from /home/anand/projects/knoldus/playing-reactive-mongo/project
[info] Set current project to playing-reactive-mongo (in build file:/home/anand/projects/knoldus/playing-reactive-mongo/)
[success] Total time: 0 s, completed 16 Jun, 2014 7:05:52 PM
[info] Updating {file:/home/anand/projects/knoldus/playing-reactive-mongo/}root…
[info] Resolving jline#jline;2.11 …
[info] Done updating.
[info] Compiling 13 Scala sources and 1 Java source to /home/anand/projects/knoldus/playing-reactive-mongo/target/scala-2.11/classes…
[success] Total time: 40 s, completed 16 Jun, 2014 7:06:32 PM
Now it’s getting compiled successfully could you please check it.
Thanks
——————
Anand Kumar Singh
Hi
Now it’s compile but I have another problem, when add one record, and then try to add another, have this error:
! @6ihgp2kc7 – Internal server error, for (POST) [/employees/save] ->
play.api.Application$$anon$1: Execution exception[[LastError: DatabaseException[‘E11000 duplicate key error index: play23.employees.$_id_ dup key: { : ObjectId(‘539fe54d2500002500eddbfc’) }’ (code = 11000)]]]
at play.api.Application$class.handleError(Application.scala:296) ~[play_2.11-2.3.0.jar:2.3.0]
at play.api.DefaultApplication.handleError(Application.scala:402) [play_2.11-2.3.0.jar:2.3.0]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$3$$anonfun$applyOrElse$4.apply(PlayDefaultUpstreamHandler.scala:320) [play_2.11-2.3.0.jar:2.3.0]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$3$$anonfun$applyOrElse$4.apply(PlayDefaultUpstreamHandler.scala:320) [play_2.11-2.3.0.jar:2.3.0]
at scala.Option.map(Option.scala:145) [scala-library-2.11.1.jar:na]
Caused by: reactivemongo.core.commands.LastError: DatabaseException[‘E11000 duplicate key error index: play23.employees.$_id_ dup key: { : ObjectId(‘539fe54d2500002500eddbfc’) }’ (code = 11000)]
at reactivemongo.core.commands.LastError$.apply(commands.scala:323) ~[reactivemongo_2.11-0.11.0-SNAPSHOT.jar:0.11.0-SNAPSHOT]
at reactivemongo.core.commands.LastError$.apply(commands.scala:321) ~[reactivemongo_2.11-0.11.0-SNAPSHOT.jar:0.11.0-SNAPSHOT]
at reactivemongo.core.commands.BSONCommandResultMaker$class.apply(commands.scala:78) ~[reactivemongo_2.11-0.11.0-SNAPSHOT.jar:0.11.0-SNAPSHOT]
at reactivemongo.core.commands.LastError$.apply(commands.scala:321) ~[reactivemongo_2.11-0.11.0-SNAPSHOT.jar:0.11.0-SNAPSHOT]
at reactivemongo.core.actors.MongoDBSystem$$anonfun$receive$1.applyOrElse(actors.scala:452) ~[reactivemongo_2.11-0.11.0-SNAPSHOT.jar:0.11.0-SNAPSHOT]
Cheers herkii
I have updated the code to create BSONObjectID at the time of insert process.
Could you please check and update me is it working now?
Now it’s working 🙂
ok have fun 🙂