code in sbt console raises java.lang.NoClassDefFoundError whereas scala repl or code in source files does not

46 Views Asked by At

I am using quill database library. my test code is along these lines:

package dtest

import io.getquill._

case class Cdl(id: Int, name: String)
inline def cdl= quote { query[Cdl] } 

def testa = { 
  val ctx=new PostgresJdbcContext(SnakeCase, "testdb")
  import ctx._
  run(cdl) 
} 

it works fine when I call it in sbt console as dtest.testa.

however, if I paste the same code in sbt console I get:

java.lang.NoClassDefFoundError: java/sql/PreparedStatement
... 62 elided
Caused by: java.lang.ClassNotFoundException: java.sql.PreparedStatement
at dotty.tools.repl.AbstractFileClassLoader.findClass$$anonfun$1(AbstractFileClassLoader.scala:44) at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15) ... etc

I can issue

scala> import java.sql.PreparedStatement

without problems, however this does not seem related to or resolve the problem.

my settings are:

scalaVersion := "3.1.1"  (3.2.1 and 3.3.0 give the same problem)
libraryDependencies ++= Seq(
  "org.postgresql"       %  "postgresql"     % "42.5.0",
  "io.getquill" %% "quill-jdbc-zio" % "4.6.0"
)
0

There are 0 best solutions below