Play2.5 scala slick configuration for mariadb - scala

I'm trying to setup a play2.5 app with slick but i'm getting an error on app startup, any clue how to fix it?
I have created the project from Play Scala Seed activator and I'm trying to add slick to the project, but for now unsuccessfully
The error :
! #72ef93323 - Internal server error, for (GET) [/] ->
play.api.http.HttpErrorHandlerExceptions$$anon$1: Execution exception[[AbstractMethodError: play.core.server.netty.NettyModelConversion$$anon$1.copy$default$11()Lscala/Option;]]
at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:269)
at play.api.http.DefaultHttpErrorHandler.onServerError(HttpErrorHandler.scala:195)
at play.core.server.Server$class.logExceptionAndGetResult$1(Server.scala:46)
at play.core.server.Server$class.getHandlerFor(Server.scala:66)
at play.core.server.NettyServer.getHandlerFor(NettyServer.scala:46)
at play.core.server.netty.PlayRequestHandler.handle(PlayRequestHandler.scala:81)
at play.core.server.netty.PlayRequestHandler.channelRead(PlayRequestHandler.scala:162)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:307)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:293)
at com.typesafe.netty.http.HttpStreamsHandler.channelRead(HttpStreamsHandler.java:131)
Caused by: java.lang.AbstractMethodError: play.core.server.netty.NettyModelConversion$$anon$1.copy$default$11()Lscala/Option;
at play.core.routing.HandlerInvokerFactory$.taggedRequest(HandlerInvoker.scala:86)
at play.core.routing.TaggingInvoker$$anon$2.tagRequest(HandlerInvoker.scala:45)
at play.api.http.DefaultHttpRequestHandler$$anonfun$4.apply(HttpRequestHandler.scala:119)
at play.api.http.DefaultHttpRequestHandler$$anonfun$4.apply(HttpRequestHandler.scala:118)
at scala.Option.map(Option.scala:146)
at play.api.http.DefaultHttpRequestHandler.handlerForRequest(HttpRequestHandler.scala:118)
at play.core.server.Server$class.getHandlerFor(Server.scala:56)
at play.core.server.NettyServer.getHandlerFor(NettyServer.scala:46)
at play.core.server.netty.PlayRequestHandler.handle(PlayRequestHandler.scala:81)
at play.core.server.netty.PlayRequestHandler.channelRead(PlayRequestHandler.scala:162)
the build.sbt
name := "play-scala"
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayScala)
scalaVersion := "2.11.7"
libraryDependencies ++= Seq(
"org.scalatestplus.play" %% "scalatestplus-play" % "1.5.0-RC1" % Test,
"com.typesafe.play" %% "play-slick" % "2.0.0",
"com.typesafe.play" %% "play-slick-evolutions" % "2.0.0",
"org.mariadb.jdbc" % "mariadb-java-client" % "1.5.5",
cache,
ws
)
resolvers += "scalaz-bintray" at "http://dl.bintray.com/scalaz/releases"
The application.conf
slick.dbs.default.driver="slick.driver.MySQLDriver$"
slick.dbs.default.db.driver="org.mariadb.jdbc.Driver"
slick.dbs.default.db.url="jdbc:mariadb://localhost:3306/test"
slick.dbs.default.db.user=******
slick.dbs.default.db.password="*******"

Related

Importing scala libraries with Maveen is refused, how to resolve this?

I am wrestling with importing required jar files and deploying them into scala projects after writing build.sbt script. Resolvers deny downloading any scala libraries from neither sonar and maveen 2 resolvers. My scala version is 2.13.0 and sbt is 1.6.1
after compiling sbt builds the program yields errors stated below.
download error: Caught java.io.IOException (Server returned HTTP
response code: 400 for URL:
https://repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.0
/scala-library-2.13.0 .pom) while downloading
https://repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.0
/scala-library-2.13.0 .pom [error] download error: Caught
java.net.URISyntaxException (Illegal character in path at index 68:
http://download.java.net/maven/2/org/scala-lang/scala-library/2.13.0
/scala-library-2.13.0 .pom) while downloading
http://download.java.net/maven/2/org/scala-lang/scala-library/2.13.0
/scala-library-2.13.0 .pom [error] download error: Caught
java.net.ConnectException (Connection refused (Connection refused))
while downloading
http://repo.typesafe.com/typesafe/releases/org/scala-lang/scala-library/2.13.0
/scala-library-2.13.0 .po [error] Error downloading
org.json4s:json4s-native_2.13.0 :3.5.1
Here is my build.sbt script which means error does'nt stem from syntax error.
lazy val commonSettings = Seq(
organization := "scala_REINFORCEMENTLEARNING",
organizationName:="trial",
scalaVersion := "2.13.0",
version := "0.1.0-SNAPSHOT"
)
lazy val root = (project in file("."))
.settings(
commonSettings,
name := "sarsamora",
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "3.2.10" % "test",
"com.typesafe" % "config" % "1.2.1",
"commons-io" % "commons-io" % "2.4",
"jline" % "jline" % "2.12.1",
"org.json4s" %% "json4s-native" % "3.5.1",
// logging
"ch.qos.logback" % "logback-classic" % "1.1.7",
"com.typesafe.scala-logging" %% "scala-logging" % "3.4.0",
"org.scala-graph" %% "graph-core" % "1.11.3",
"org.scalanlp" %% "breeze" % "0.13",
"org.scalanlp" %% "breeze-natives" % "1.1",
"org.scalanlp" %% "breeze-viz" % "1.1",
"org.jfree" % "jfreechart" % "1.0.19"
)
)
lazy val compiler = (project in file(".")).dependsOn(root)
.settings(commonSettings:_*)
resolvers ++= Seq(
("Typesafe" at "http://repo.typesafe.com/typesafe/releases/").withAllowInsecureProtocol(true),
("Java.net Maven2 Repository" at "http://download.java.net/maven/2/").withAllowInsecureProtocol(true),
)
Look's like you've got an extra whitespace in your version number:
https://repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.0/scala-library-2.13.0 .pom
Fix the Scala version in your build.sbt and it should be it.

Resolver for spring-data-neo4j

I want to use spring-data-neo4j with play framework 2.6 in Scala. But when I add the library dependency I have a compilation error:
object neo4j is not a member of package org
for
import org.neo4j.ogm.annotation.{GraphId, NodeEntity}
I think I don't have good resolvers:
name := """Project-name"""
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayScala)
resolvers += Resolver.sonatypeRepo("snapshots")
scalaVersion := "2.12.2"
libraryDependencies ++= Seq(
guice,
"org.scalatestplus.play" %% "scalatestplus-play" % "3.0.0" % Test,
"com.h2database" % "h2" % "1.4.194",
"org.springframework.data" % "spring-data-neo4j" % "4.2.6.RELEASE"
)
The classes you are trying to import import org.neo4j.ogm.annotation.{GraphId, NodeEntity} is part of neo4j-ogm-core artifact. so you must include it as shown below to able to access those classes.
libraryDependencies += "org.neo4j" % "neo4j-ogm-core" % "3.0.0-RC1"

Can not create a multi project build

I am trying to create a Play application with a back end and a front end(using Scala.js). I separated the code into client and server folders.
For creating a Multi Project Build I looked at this http://www.scala-sbt.org/release/docs/Multi-Project.html and make my build.sbt like this:
name := """ScalaWeb"""
version := "1.0-SNAPSHOT"
lazy val commonSettings = Seq(
scalaVersion := "2.11.7",
libraryDependencies ++= Seq(
jdbc,
cache,
ws,
specs2 % Test
),
libraryDependencies ++= Seq(
"org.sorm-framework" % "sorm" % "0.3.19",
"org.scala-lang" % "scala-compiler" % scalaVersion.value force(),
"com.h2database" % "h2" % "1.3.148"
),
libraryDependencies += "com.typesafe.scala-logging" %% "scala-logging" % "3.1.0",
/*libraryDependencies += "com.typesafe.scala-logging" %% "scala-logging" % "3.1.0",
libraryDependencies += "org.slf4j" % "slf4j-api" % "1.7.12"
libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.1.3"*/
resolvers += "scalaz-bintray" at "http://dl.bintray.com/scalaz/releases",
// Play provides two styles of routers, one expects its actions to be injected, the
// other, legacy style, accesses its actions statically.
routesGenerator := InjectedRoutesGenerator,
scalacOptions += "-Ylog-classpath",
// use this if you just want jawn's parser, and will implement your own facade
libraryDependencies += "org.spire-math" %% "jawn-parser" % "0.8.3",
// use this if you want jawn's parser and also jawn's ast
libraryDependencies += "org.spire-math" %% "jawn-ast" % "0.8.3",
//for reading Json libraries
libraryDependencies += "org.scalaj" %% "scalaj-http" % "2.2.1"
)
lazy val server = (project in file("server")).settings(
commonSettings: _*
).enablePlugins(PlayScala)
lazy val client = (project in file("client")).settings(
commonSettings: _*
).enablePlugins(PlayScala)
fork in run := true
So basically I placed all dependencies into commonSettings and the imported that into the client and server projects.
However, I am getting this error:
[error] (scalaweb/compile:backgroundRun) No main class detected.
Why is this occuring?
Have I set up my build.sbt incorrectly?
That's because your root project (scalaweb) doesn't have a main class.
You can either:
run server's run command by doing: server/run
aggregate client and server under root project
(http://www.scala-sbt.org/0.13/docs/Multi-Project.html#Aggregation)
This might do what you wish.

sbt runtime classPath does not match compile classPath, causes java.lang.NoClassDefFoundError

Runtime classpath according to 'show runtime:fullClasspath' contains only target/scala-2.11/classes and ~/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.11.7.jar.
compile:fullClasspath contains all libraryDependencies jar locations under ~/.ivy2/cache. Why is this? I am getting java.lang.NoClassDefFoundError on sbt run.
build.sbt:
name := "my-server"
version := "1.0"
scalaVersion := "2.11.7"
libraryDependencies ++= List(
"com.typesafe.slick" %% "slick" % "3.1.0" % "provided",
"com.twitter.finatra" %% "finatra-http" % "2.1.0" % "provided",
"com.roundeights" %% "hasher" % "1.2.0" % "provided",
"com.twitter" %% "util-logging" % "6.29.0" % "provided"
)
resolvers +=
"Twitter" at "http://maven.twttr.com"
resolvers ++= Seq("RoundEights" at "http://maven.spikemark.net/roundeights")
sbt run results:
Exception in thread "main" java.lang.NoClassDefFoundError: com/twitter/logging/Logger
sbt version 0.13.8
Removing "provided" was the fix here - I was using it incorrectly to resolve ambiguous subversions of dependencies (credit to pfn from freenode #scala)

How to declare play json dependency?

My build.sbt file (sbt version is 0.13.8):
lazy val commonSettings = Seq(
version := "1.0.0",
scalaVersion := "2.11.6"
)
resolvers += "Typesafe Repo" at "http://repo.typesafe.com/typesafe/releases/"
lazy val root = (project in file(".")).
settings(commonSettings: _*).
settings(
name := "myapp",
libraryDependencies ++= Seq(
"com.typesafe.play" % "play-json" % "2.3.4",
"org.scalatest" % "scalatest_2.11" % "2.2.4" % "test",
"junit" % "junit" % "4.12" % "test"
)
)
scalacOptions ++= Seq("-unchecked", "-feature", "-deprecation")
I get this error when trying to compile my project:
[trace] Stack trace suppressed: run last *:update for the full output.
[error] (*:update) sbt.ResolveException: unresolved dependency: com.typesafe.play#play-json_2.11;2.3.4: not found
[error] Total time: 0 s, completed Apr 17, 2015 5:59:28 PM
How can I get this play-json library for my scala 2.11.6?
You need to tell sbt which scala version should use.
You can either be explicit:
"com.typesafe.play" % "play-json_2.11" % "2.3.4",
Or use %% (sbt doc) as follows to tell sbt to use scalaVersion :
"com.typesafe.play" %% "play-json" % "2.3.4",
You can see all of com.typesafe.play's play-json versions here. They don't have a 2.3.4 version; try using 2.4.0-M3 instead.
"com.typesafe.play" %% "play-json" % "2.4.0-M3"
Mind the double %% so scalaVersion is used properly to resolve the dependency.