0

I get below error when I run the unit tests using sbt console twice or more. I do not get any error when I run for the first time. If I get out from Sbt (Ctrl+D) and go back to Sbt, there is no issue with running the tests for the first time.Using IntelliJ.

My test suites contain many test cases like below

                    val timeOutSpan = 5
                    val intervalSpan = 500
                    implicit val defaultPatience =
                        PatienceConfig(timeout = Span(timeOutSpan, Seconds), interval = Span(intervalSpan, Millis))

                     it should "get houses" in {
                            val index: Future[Result] = destinations.index
                                .apply(FakeRequest(GET, "/houses"))
                            whenReady(index){ index =>
                                index.header.status shouldBe 200
                            }
                        }

Getting below error

    java.lang.ExceptionInInitializerError
    at play.api.http.HttpConfiguration$.current(HttpConfiguration.scala:149)
    at play.api.mvc.GlobalStateHttpConfiguration$.httpConfiguration(Http.scala:22)
    at play.api.mvc.Session$.path(Http.scala:713)
    at play.api.i18n.DefaultMessagesApi.setLang(Messages.scala:502)
    at play.api.i18n.I18nSupport$ResultWithLang.withLang(I18nSupport.scala:49)
    at controllers.BaseController.decorate(BaseController.scala:38)
    at modules.home.controllers.Home$$anonfun$index$1$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$3$$anonfun$apply$4$$anonfun$apply$5$$anonfun$apply$9$$anonfun$apply$10.apply(Home.scala:51)
    at modules.home.controllers.Home$$anonfun$index$1$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$3$$anonfun$apply$4$$anonfun$apply$5$$anonfun$apply$9$$anonfun$apply$10.apply(Home.scala:40)
    at scala.util.Success$$anonfun$map$1.apply(Try.scala:237)
    at scala.util.Try$.apply(Try.scala:192)
    at scala.util.Success.map(Try.scala:237)
    at scala.concurrent.Future$$anonfun$map$1.apply(Future.scala:237)
    at scala.concurrent.Future$$anonfun$map$1.apply(Future.scala:237)
    at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32)
    at scala.concurrent.impl.ExecutionContextImpl$AdaptedForkJoinTask.exec(ExecutionContextImpl.scala:121)
    at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
    at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
    at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
    at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
Caused by: java.lang.ClassCastException: org.apache.xerces.parsers.XIncludeAwareParserConfiguration cannot be cast to org.apache.xerces.xni.parser.XMLParserConfiguration
    at org.apache.xerces.parsers.SAXParser.<init>(Unknown Source)
    at org.apache.xerces.parsers.SAXParser.<init>(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.<init>(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserImpl.<init>(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserImpl.<init>(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserFactoryImpl.newSAXParserImpl(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserFactoryImpl.setFeature(Unknown Source)
    at play.api.Play$.<init>(Play.scala:46)
    at play.api.Play$.<clinit>(Play.scala)
    ... 19 more
ecamur
  • 99
  • 1
  • 4
  • 1
    why you do not try to use `2.5.12` ? see if this issue happen? i'm not sure but there was an issue around this part in first 2.5.x versions – Al-Mothafar Feb 01 '17 at 22:20
  • @Al-Mothafar I tried your suggestion but I get the same error. I am looking into this [link](http://stackoverflow.com/questions/34413/why-am-i-getting-a-noclassdeffounderror-in-java/34419#34419) post and still looking for a solution. – ecamur Feb 02 '17 at 16:16

1 Answers1

0

Including OneAppPerSuite in my test suite solved the issue.

class ExampleSpec extends FlatSpec with OneAppPerSuite {

       test cases go here
} 

details about OneAppPerSuite is here

ecamur
  • 99
  • 1
  • 4