Play 2.1.1、slick、および MySQL を使用して作成した約 1 か月のプロジェクトがあります。今、これを MSSQL に移行する必要がありますが、いくつかの問題があります。
私のアプリケーションは正常にコンパイルされ、ドライバーが見つかりますが、接続しようとすると[RuntimeException: java.lang.ExceptionInInitializerError]
サイトにエラーが表示され、コンソールに次のような詳細なエラーが表示されます。
play.api.Application$$anon$1: Execution exception[[RuntimeException: java.lang.ExceptionInInitializerError]]
at play.api.Application$class.handleError(Application.scala:289) ~[play_2.10.jar:2.1.1]
at play.api.DefaultApplication.handleError(Application.scala:383) ~[play_2.10.jar:2.1.1]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$17$$anonfun$apply$24.apply(PlayDefaultUpstreamHandler.scala:326) ~[play_2.10.jar:2.1.1]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$17$$anonfun$apply$24.apply(PlayDefaultUpstreamHandler.scala:324) ~[play_2.10.jar:2.1.1]
at play.api.libs.concurrent.PlayPromise$$anonfun$extend1$1.apply(Promise.scala:113) ~[play_2.10.jar:2.1.1]
at play.api.libs.concurrent.PlayPromise$$anonfun$extend1$1.apply(Promise.scala:113) ~[play_2.10.jar:2.1.1]java.lang.RuntimeException: java.lang.ExceptionInInitializerError
at play.api.mvc.ActionBuilder$$anon$1.apply(Action.scala:222) ~[play_2.10.jar:2.1.1]
at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$5$$anonfun$apply$6.apply(Action.scala:109) ~[play_2.10.jar:2.1.1]
at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$5$$anonfun$apply$6.apply(Action.scala:109) ~[play_2.10.jar:2.1.1]
at play.utils.Threads$.withContextClassLoader(Threads.scala:18) ~[play_2.10.jar:2.1.1]
at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$5.apply(Action.scala:108) ~[play_2.10.jar:2.1.1]
at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$5.apply(Action.scala:106) ~[play_2.10.jar:2.1.1]Caused by: java.lang.ExceptionInInitializerError: null
at controllers.Application$$anonfun$addLicense$1.apply(Application.scala:18) ~[na:na]
at controllers.Application$$anonfun$addLicense$1.apply(Application.scala:17) ~[na:na]
at play.api.mvc.ActionBuilder$$anon$1.apply(Action.scala:217) ~[play_2.10.jar:2.1.1]
at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$5$$anonfun$apply$6.apply(Action.scala:109) ~[play_2.10.jar:2.1.1]
at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$5$$anonfun$apply$6.apply(Action.scala:109) ~[play_2.10.jar:2.1.1]
at play.utils.Threads$.withContextClassLoader(Threads.scala:18) ~[play_2.10.jar:2.1.1]
Caused by: play.api.Configuration$$anon$1: Configuration error[Slick error : Unknown jdbc driver found in application.conf: [net.sourceforge.jtds.jdbc.Driver]]
at play.api.Configuration$.play$api$Configuration$$configError(Configuration.scala:80) ~[play_2.10.jar:2.1.1]
at play.api.Configuration.reportError(Configuration.scala:558) ~[play_2.10.jar:2.1.1]
at play.api.db.slick.Config$.driver(Config.scala:21) ~[play-slick_2.10-0.3.3.jar:0.3.3]
at play.api.db.slick.Config$.driver$lzycompute(Config.scala:7) ~[play-slick_2.10-0.3.3.jar:0.3.3]
at play.api.db.slick.Config$.driver(Config.scala:7) ~[play-slick_2.10-0.3.3.jar:0.3.3]
at models.License$.<init>(License.scala:38) ~[na:na]
私が見つけた中で最も興味深いのは、次の行です。
Caused by: play.api.Configuration$$anon$1: Configuration error[Slick error : Unknown jdbc driver found in application.conf: [net.sourceforge.jtds.jdbc.Driver]]
間違った名前を入力するとエラーが発生するため、ドライバーが見つかりました。これを入力してもエラーは発生しません。ディレクトリに jtds ドライバーがありlib
ます。
また、起動時にデータベースに接続します
[info] play - database [default] connected at jdbc:jtds:sqlserver://ServerAddress/EGLC
いくつかの追加情報:
application.conf :
db.default.url="jdbc:jtds:sqlserver://ServerAddress/EGLC"
db.default.driver=net.sourceforge.jtds.jdbc.Driver
db.default.user="sa"
db.default.password="pass"
slick.default="models.*"
Build.scala :
val appDependencies = Seq(
// Add your project dependencies here,
jdbc,
"mysql" % "mysql-connector-java" % "5.1.25",
"net.sourceforge.jtds" % "jtds" % "1.3.1",
"com.typesafe.play" %% "play-slick" % "0.3.3"
)
EDITページを更新すると、jtdsについても言及していない新しいエラーセットで別の例外が発生します
play.api.Application$$anon$1: Execution exception[[RuntimeException: java.lang.NoClassDefFoundError: Could not initialize class models.Location$]]
at play.api.Application$class.handleError(Application.scala:289) ~[play_2.10.jar:2.1.1]
at play.api.DefaultApplication.handleError(Application.scala:383) ~[play_2.10.jar:2.1.1]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$17$$anonfun$apply$24.apply(PlayDefaultUpstreamHandler.scala:326) ~[play_2.10.jar:2.1.1]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$17$$anonfun$apply$24.apply(PlayDefaultUpstreamHandler.scala:324) ~[play_2.10.jar:2.1.1]
at play.api.libs.concurrent.PlayPromise$$anonfun$extend1$1.apply(Promise.scala:113) ~[play_2.10.jar:2.1.1]
at play.api.libs.concurrent.PlayPromise$$anonfun$extend1$1.apply(Promise.scala:113) ~[play_2.10.jar:2.1.1]java.lang.RuntimeException: java.lang.NoClassDefFoundError: Could not initialize class models.Location$
at play.api.mvc.ActionBuilder$$anon$1.apply(Action.scala:222) ~[play_2.10.jar:2.1.1]
at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$5$$anonfun$apply$6.apply(Action.scala:109) ~[play_2.10.jar:2.1.1]
at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$5$$anonfun$apply$6.apply(Action.scala:109) ~[play_2.10.jar:2.1.1]
at play.utils.Threads$.withContextClassLoader(Threads.scala:18) ~[play_2.10.jar:2.1.1]
at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$5.apply(Action.scala:108) ~[play_2.10.jar:2.1.1]
at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$5.apply(Action.scala:106) ~[play_2.10.jar:2.1.1]
Caused by: java.lang.NoClassDefFoundError: Could not initialize class models.Location$
at controllers.Application$$anonfun$locations$1$$anonfun$apply$12$$anonfun$apply$13.apply(Application.scala:47) ~[na:na]
at controllers.Application$$anonfun$locations$1$$anonfun$apply$12$$anonfun$apply$13.apply(Application.scala:46) ~[na:na]
at controllers.Secured$$anonfun$IsAuthenticated$3$$anonfun$apply$3.apply(Auth.scala:38) ~[na:na]
at controllers.Secured$$anonfun$IsAuthenticated$3$$anonfun$apply$3.apply(Auth.scala:38) ~[na:na]
at play.api.mvc.ActionBuilder$$anon$1.apply(Action.scala:217) ~[play_2.10.jar:2.1.1]
at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$5$$anonfun$apply$6.apply(Action.scala:109) ~[play_2.10.jar:2.1.1]