1

I'm new to Play framework. I'm trying to configure MongoDB database as a datasource to be used with Play framework 2.4. But I am unable to find any tutorial or steps which can guide me to have connection of my "Hello world" application with mongoDB. I just need to know how can I use mongoDB with the current play version? Just need to understand the basic CRUD operations b/w mongodb and play framework using java (not scala).

2 Answers 2

2

You can use PlayJongo Play 2.4.x Module.

It is a Play 2.4.x Module for Jongo (a MongoDB Java driver wrapper).

Sign up to request clarification or add additional context in comments.

Comments

1

see this answer https://stackoverflow.com/a/11754368/5034081

it explains how to add the java driver for your application. but you have to be careful because interacting with database is a blocking action and if you block your threads you will have troubles. read the official doc on how to solve this problem. https://www.playframework.com/documentation/2.1.0/ThreadPools

there is also other libs like this for using mongo in a play application. https://github.com/vznet/play-mongo-jackson-mapper

8 Comments

Thank you for the useful information. I have read about MongoDB Jackson Mapper Plugin (Java). The connection is also established between application and mongodb. using this link - link But here the version is 2.0..So will it work for play2.4? And interaction of jackson with mongodb is non -blocking??
the link you provided has the version 2.3.1. i think it should work fine with 2.4, not sure. NO interaction with db is blocking and you have to do your db calls in another thread and return a Promise object for the main thread.
It gives me this error...(No Idea Why...?) ConfigurationException: Guice configuration errors: 1) Could not find a suitable constructor in play.modules.mongodb.jackson.MongoDBPlugin. Classes must have either one (and only one) constructor annotated with @Inject or a zero-argument constructor that is not private. at play.modules.mongodb.jackson.MongoDBPlugin.class(MongoDB.scala:163) while locating play.modules.mongodb.jackson.MongoDBPlugin
i think the plugin doesn't support 2.4 version since it uses guice for dependency injection. you can ask the plugin owner to migrate it to 2.4 version.
Yes it is not compatible with the current play version... found here. You have any other idea.. which plugin to use??
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.