NullPointerException on executing concurrent queries using Slick NullPointerException on executing concurrent queries using Slick postgresql postgresql

NullPointerException on executing concurrent queries using Slick


I think you have found this issue. Try to use lazy val for db so it only initializes once:

object DriverHelper {  val user = "postgres"  val url = "jdbc:postgresql://192.168.1.50:5432/MyDatabase"  val password = "password"  val jdbcDriver = "org.postgresql.Driver"  lazy val db: PostgresDriver.backend.DatabaseDef = Database.forURL(url, user = user, password = password, driver = jdbcDriver)}


Just sharing the information for anyone else facing this issue.

There was a bug with Slick itself. It was reported here. Git user, mustajavi fixed this and was merged to latest Slick branch. With the latest update of 3.1.1, the issue is resolved for me.

Related Links in GitHub:

https://github.com/slick/slick/pull/1401

https://github.com/slick/slick/pull/1445