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.

About the Author: Anand Kumar Singh

Hi, I’m Anand Singh and I specialize in Computer Software. I’m passionate about what I do, and I love to help people. Nothing is more fulfilling than being part of a team with similar interests, and an organization that values its employees. I'm Lead Software Engineer at Sapient. Having 5+ years of experience in Java, Grails/Groovy and Scala language. Anand also knows about Javascript, jQuery, CSS and other UI design technologies. Certified developer in: * Principles of Reactive Programming – Coursera * Functional Programming Principles in Scala – Coursera * Functional Program Design in Scala – Coursera * Introduction to Big Data with Apache Spark – edX * Oracle Certified Associate (OCA) * Sun Certified Java Programmer (SCJP) I'm passionate to work with upcoming technologies and bleeding platforms providing the new way to programming & development. He is actively involved in development & maintenance of several software projects. He has been enjoying Scala for more than a year now. Anand completed his MCA from IGNOU. As a Developer, I'm continuing my journey by actively collaborating with other Developers in my field. I'm actively contributing on the TechMonad & Playing Scala platform. I likes to spend his free time in Cooking, watching Discovery for new Technology and visiting new places with friends.


    1. 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.

      Anand Kumar Singh

      1. 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-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

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s