ses
ses

Reputation: 13352

playframework 2.0 scala - No suitable driver found in tests

I was following this tutorial to star using playframework2.1 RC1 + Slick.

When try launch the SoftwareSpec test (that tests Model-like class):

play test

they fail with an error like this:

[error] SQLException: No suitable driver found for jdbc:h2:mem:test1 (DriverManager.java:190) [error] SoftwareSpec$$anonfun$1$$anonfun$apply$3.apply(SoftwareSpec.scala:25) [error] SoftwareSpec$$anonfun$1$$anonfun$apply$3.apply(SoftwareSpec.scala:25)

But I've enabled h2 db in application.conf like was mentioned in that article.

I've used latest dependencies to slick, in Build.scala file:

"com.typesafe" % "slick_2.10.0-RC1" % "1.0.0-RC1"

Once, when I changed dependency to slick to this version:

"com.typesafe" % "slick_2.10.0-RC1" % "0.11.2"

then the test was passed successfully. But after I change the test to make it fail, the error came back again - "No suitable driver". And after this all my tries (like play clean whatever) were unsuccessful.

Upvotes: 2

Views: 1376

Answers (2)

Kazuhiro Sera
Kazuhiro Sera

Reputation: 1877

I got the same error when running tests on Travis CI.

A work around is loading JDBC driver class like Class.forName("org.h2.Driver").

https://github.com/seratch/scalikejdbc/blob/564cc07505d7a9f217945a7f2c07dc2c7460ed87/scalikejdbc-play-plugin/src/test/scala/scalikejdbc/PlayPluginSpec.scala#L15

Of course, I should investigate the reason of this issue and report to the Play team but I haven't done.

Upvotes: 2

Jack
Jack

Reputation: 16728

I'm not using Play at the moment, so I can't test the following, but it should be fine. For the latest Slick, you can use:

"com.typesafe" % "slick_2.10" % "1.0.0-RC1"

For h2, the following should work:

"com.h2database" % "h2" % "1.3.166"

Upvotes: 0

Related Questions