from reactivemongo 0.11.6 to 0.11.11 (& play 2.3 to play 2.4)

146 views
Skip to first unread message

Ugo Bourdon

unread,
Apr 5, 2016, 12:09:57 PM4/5/16
to ReactiveMongo - http://reactivemongo.org
Hi,

I try to migrate my play 2.3.10 play app ot play 2.4.6.

For that i upgrade my reactivemongo library from 0.11.6 to 0.11.11.

When i launch my unit test on mongo repository, i have some troubles :

eactivemongo.core.errors.ConnectionNotInitialized: MongoError['Connection is missing metadata (like protocol version, etc.) The connection pool is probably being initialized.']
[info]   at reactivemongo.core.errors.ConnectionNotInitialized$.MissingMetadata(errors.scala:71)
[info]   at reactivemongo.api.collections.GenericCollection$class.insert(genericcollection.scala:364)
[info]   at reactivemongo.play.json.collection.JSONCollection.insert(collection.scala:377)
[info]   at infrastructure.repository.mongodb.MongoDbCompanyRepository$$anonfun$insert_impl$1.apply(MongoDbCompanyRepository.scala:22)
[info]   at infrastructure.repository.mongodb.MongoDbCompanyRepository$$anonfun$insert_impl$1.apply(MongoDbCompanyRepository.scala:21)
[info]   at infrastructure.repository.mongodb.MongoDbCompanyRepositoryTest$$anonfun$1.apply$mcV$sp(MongoDbCompanyRepositoryTest.scala:38)
[info]   at infrastructure.repository.mongodb.MongoDbCompanyRepositoryTest$$anonfun$1.apply(MongoDbCompanyRepositoryTest.scala:35)
[info]   at infrastructure.repository.mongodb.MongoDbCompanyRepositoryTest$$anonfun$1.apply(MongoDbCompanyRepositoryTest.scala:35)
[info]   at org.scalatest.Transformer$$anonfun$apply$1.apply$mcV$sp(Transformer.scala:22)
[info]   at org.scalatest.OutcomeOf$class.outcomeOf(OutcomeOf.scala:85)

For create my connection I use this code :

implicit val connection: DB = {
   val driver = new MongoDriver
   val connection = driver.connection(List("localhost:27042"))
   connection("test")
}

Have you any idea of what i'm missing ?

Of course, this code work fine in previous version of reactivemongo.

Thx for your responses.


Cédric Chantepie

unread,
Apr 5, 2016, 5:24:38 PM4/5/16
to ReactiveMongo - http://reactivemongo.org
Try using connection.database(..) instead.
Message has been deleted

Ugo Bourdon

unread,
Apr 12, 2016, 4:51:07 AM4/12/16
to ReactiveMongo - http://reactivemongo.org
I tried connection.database but that change nothing. Seems it can't retrieve the connection.
An config option could explain that ?

Le mardi 5 avril 2016 23:24:38 UTC+2, Cédric Chantepie a écrit :
Try using connection.database(..) instead.

Ugo Bourdon

unread,
Apr 12, 2016, 4:55:16 AM4/12/16
to ReactiveMongo - http://reactivemongo.org
When I launch mongo instance myself it works fine.
But in my test I use https://github.com/flapdoodle-oss/de.flapdoodle.embed.mongo

In the previous version of reactivemongo it works well together.

Cédric Chantepie

unread,
Apr 12, 2016, 5:58:36 AM4/12/16
to ReactiveMongo - http://reactivemongo.org


On Tuesday, 12 April 2016 10:55:16 UTC+2, Ugo Bourdon wrote:
When I launch mongo instance myself it works fine.

What do you mean?


Le mardi 12 avril 2016 10:51:07 UTC+2, Ugo Bourdon a écrit :
I tried connection.database but that change nothing. Seems it can't retrieve the connection.
An config option could explain that ?

Le mardi 5 avril 2016 23:24:38 UTC+2, Cédric Chantepie a écrit :
Try using connection.database(..) instead.

Have you tried the examples in the doc with your URI (see Connect Using MongoDB URI)?

Ugo Bourdon

unread,
Apr 14, 2016, 4:54:24 AM4/14/16
to ReactiveMongo - http://reactivemongo.org
If i launch a local mongoDB et launch my test it is ok.
But if i launch a mongodb instance via my test it doesn't work.
I feel the second case the database have specific option that not allow connection. (but it is not credentials)

Cédric Chantepie

unread,
Apr 14, 2016, 7:18:10 AM4/14/16
to ReactiveMongo - http://reactivemongo.org
Try not to stop the MongoDB instance, to check it's properly started by connecting to, first with the Mongo shell then with the ReactiveMongo connection sample.

Ugo Bourdon

unread,
Apr 18, 2016, 11:02:59 AM4/18/16
to ReactiveMongo - http://reactivemongo.org
I reproduce the issue with distant mongo database (on clevercloud Paas) with that error message

reactivemongo.core.errors.ConnectionNotInitialized: MongoError['Connection is missing metadata (like protocol version, etc.) The connection pool is probably being initialized.']

[info]   at reactivemongo.core.errors.ConnectionNotInitialized$.MissingMetadata(errors.scala:71)
[info]   at reactivemongo.api.collections.GenericCollection$class.insert(genericcollection.scala:364)
[info]   at reactivemongo.play.json.collection.JSONCollection.insert(collection.scala:377)

Ugo Bourdon

unread,
Apr 18, 2016, 11:40:47 AM4/18/16
to ReactiveMongo - http://reactivemongo.org
And I try to connect with the shell to this database and it is up.

Cédric Chantepie

unread,
Apr 18, 2016, 11:58:13 AM4/18/16
to ReactiveMongo - http://reactivemongo.org
The call to connection.database(..) is successfull but you get this error when call insert on a collection resolved from this same resolved DB ?

Ugo Bourdon

unread,
Apr 18, 2016, 12:06:17 PM4/18/16
to ReactiveMongo - http://reactivemongo.org
Yes exactly ! I try to perform read OP and it's ok, but for write operation (drop, insert etc...) not.

Ugo Bourdon

unread,
Apr 18, 2016, 12:44:15 PM4/18/16
to ReactiveMongo - http://reactivemongo.org
In fact it depends ...
In my test it fail immediatly ...

With my test, it fail immediatly when i try to create connection.
But when I try it in a script to contact distant database, read

Cédric Chantepie

unread,
Apr 18, 2016, 12:56:44 PM4/18/16
to ReactiveMongo - http://reactivemongo.org
So there 2 separate issues. 1. Connection to a remote DB. 2. Trying to read/write with a DB not obtained with the new .database(..) function (with the no metadata error).

The second is easy to solve, no longer using the deprecated DB resolution function (nowhere).

The first one, can be solve by setting a failover appropriate to the latency between your app and the MongoDB remote RS.

Ugo Bourdon

unread,
Apr 18, 2016, 1:13:13 PM4/18/16
to ReactiveMongo - http://reactivemongo.org
I find the issue for my test (and i think for all my issues).
If i declare lazy val instead of val for the referenceof the connection AND the reference of my mongo collection from connection it's works.
connection.database change nothing for the bug, but i will use it of course.

Cédric Chantepie

unread,
Apr 18, 2016, 2:18:45 PM4/18/16
to ReactiveMongo - http://reactivemongo.org
Initialization order issues are quite usual in tests (not specific to Mongo).
Reply all
Reply to author
Forward
0 new messages