Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8473813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:27:21+00:00 2026-06-10T17:27:21+00:00

I thought I had fixed the problem temporarily, but it turns out I am

  • 0

I thought I had fixed the problem temporarily, but it turns out I am still having problems.

I am trying to create some specs2 tests for my models layer, I would like to insert some dummy object, and then run some queries to make sure data comes out as expected. Here is what my simple test looks like:

class ModelSpec extends Specification {

    override def is = args(sequential = true) ^ super.is

    object FakeApp extends FakeApplication()

    running(FakeApp){
        println("set up database")
        val newUser = User(
                    email = "wfbarksdale@gmail.com",
                    username = "weezybizzle",
                    password = "nutterbutter")
        User.save(newUser)
    }

    running(FakeApp) {
        "User Model" should {
            "be created and retrieved by username" in {
                println("finding someone")
                User.findOneByUsername("weezybizzle") must beSome
            }
            "not find non existant user" in {
                println("finding nobody")
                User.findOneByUsername("nobody") must beNone
            }
        }
    }
}

And here is the stack trace I get from the unit tests:

[info] Compiling 1 Scala source to /www/mojulo3/target/scala-2.9.1/test-classes...
set up database
finding someone
finding nobody
[info] ModelSpec
[info] 
[info] User Model should
[error] ! be created and retrieved by username
[error]     IllegalStateException: this Mongo has been closed (DBTCPConnector.java:123)
[error] com.mongodb.DBTCPConnector._checkClosed(DBTCPConnector.java:123)
[error] com.mongodb.DBTCPConnector.call(DBTCPConnector.java:207)
[error] com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:313)
[error] com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:298)
[error] com.mongodb.DBCollection.findOne(DBCollection.java:682)
[error] com.mongodb.DBCollection.findOne(DBCollection.java:661)
[error] com.mongodb.casbah.MongoCollectionBase$class.findOne(MongoCollection.scala:225)
[error] com.mongodb.casbah.MongoCollection.findOne(MongoCollection.scala:897)
[error] com.novus.salat.dao.SalatDAO.findOne(SalatDAO.scala:311)
[error] models.User$.findOneByUsername(User.scala:24)
[error] test.ModelSpec$$anonfun$3$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$3.apply(ModelSpec.scala:29)
[error] test.ModelSpec$$anonfun$3$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$3.apply(ModelSpec.scala:29)
[error] test.ModelSpec$$anonfun$3$$anonfun$apply$1$$anonfun$apply$2.apply(ModelSpec.scala:29)
[error] test.ModelSpec$$anonfun$3$$anonfun$apply$1$$anonfun$apply$2.apply(ModelSpec.scala:27)
[error] ! not find non existant user
[error]     IllegalStateException: this Mongo has been closed (DBTCPConnector.java:123)
[error] com.mongodb.DBTCPConnector._checkClosed(DBTCPConnector.java:123)
[error] com.mongodb.DBTCPConnector.call(DBTCPConnector.java:207)
[error] com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:313)
[error] com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:298)
[error] com.mongodb.DBCollection.findOne(DBCollection.java:682)
[error] com.mongodb.DBCollection.findOne(DBCollection.java:661)
[error] com.mongodb.casbah.MongoCollectionBase$class.findOne(MongoCollection.scala:225)
[error] com.mongodb.casbah.MongoCollection.findOne(MongoCollection.scala:897)
[error] com.novus.salat.dao.SalatDAO.findOne(SalatDAO.scala:311)
[error] models.User$.findOneByUsername(User.scala:24)
[error] test.ModelSpec$$anonfun$3$$anonfun$apply$1$$anonfun$apply$6$$anonfun$apply$7.apply(ModelSpec.scala:35)
[error] test.ModelSpec$$anonfun$3$$anonfun$apply$1$$anonfun$apply$6$$anonfun$apply$7.apply(ModelSpec.scala:35)
[error] test.ModelSpec$$anonfun$3$$anonfun$apply$1$$anonfun$apply$6.apply(ModelSpec.scala:35)
[error] test.ModelSpec$$anonfun$3$$anonfun$apply$1$$anonfun$apply$6.apply(ModelSpec.scala:33)
[info]  
[info]  
[info] Total for specification ModelSpec
[info] Finished in 20 ms
[info] 2 examples, 0 failure, 2 errors
[info] 
[error] Error: Total 2, Failed 0, Errors 2, Passed 0, Skipped 0
[error] Error during tests:
[error]     test.ModelSpec
[error] {file:/www/mojulo3/}mojulo3/test:test: Tests unsuccessful
[error] Total time: 4 s, completed Aug 28, 2012 10:02:33 PM

It looks like the FakeApp is somehow disconnecting from the database, and not reconnecting. I looked into the Play source, and it seems that the application will be stopped and restarted, regardless of whether or not it is actually the same object. I am thinking that the issue may be stemming from the salat onStop() method or onStart() but I am not really sure.

I have been struggling for a while with this, any help, even just on how to reason about the problem, would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T17:27:22+00:00Added an answer on June 10, 2026 at 5:27 pm

    This is because it closes the MongoDB connection in the plugin’s onStop method. I’ve submitted a pull request so that this doesn’t happen during testing:

    https://github.com/leon/play-salat/pull/27

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I thought I had this figured out but it turns out I'm just deleting
I thought I had fixed this on Friday through a type correction, but I
I am trying to create a layout using a fixed header and sidebar but
So I thought I had fixed the problem posted in this question and I
I had thought I was clever. But in light of recent discoveries, I'm not
I thought I had resolved this but I obviously haven't and was hoping someone
Alright, I thought I had this whole setTimeout thing perfect but I seem to
This problem is very simple, but I just can't figure it out added to
I though I had solved this problem, but it is back: Code generation for
Today I had a problem with some routing in my ASP.NET MVC 3 application

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.