configuring Play framework with Scala to use Neo4j graph db - scala

I'm using scala in my app, it run without problem, but if I add neo4j in the dependencies, it throws a NoSuchMethod error. I didn't even have references to any neo4j classes in my code...
I have no problem using play framework with scala, or play framework (Java) with neo4j, just when using both together, it crash...
and I tried both neo4j 1.4.2 and 1.5.M02 to no avail.
thanks for any help~
Chris
dependencies.yml
# Application dependencies
require:
- play
- play -> scala 0.9.1
- org.neo4j -> neo4j 1.4.2
exception details:
play.exceptions.UnexpectedException: Unexpected Error
at play.Invoker$Invocation.onException(Invoker.java:232)
at play.Invoker$Invocation.run(Invoker.java:273)
at Invocation.HTTP Request(Play!)
Caused by: java.lang.NoSuchMethodError: scala.collection.generic.GenericTraversableTemplate.flatten(Lscala/Function1;)Lscala/collection/Traversable;
at play.scalasupport.compiler.PlayScalaCompiler$.scanFiles(ScalaCompiler.scala:18)
at play.scalasupport.compiler.PlayScalaCompiler$$anonfun$scanFiles$1.apply(ScalaCompiler.scala:17)
at play.scalasupport.compiler.PlayScalaCompiler$$anonfun$scanFiles$1.apply(ScalaCompiler.scala:15)
at play.scalasupport.compiler.PlayScalaCompiler$.scanFiles(ScalaCompiler.scala:15)
at play.scalasupport.compiler.PlayScalaCompiler$$anonfun$scanFiles$1.apply(ScalaCompiler.scala:17)
at play.scalasupport.compiler.PlayScalaCompiler$$anonfun$scanFiles$1.apply(ScalaCompiler.scala:15)
at play.scalasupport.compiler.PlayScalaCompiler$.scanFiles(ScalaCompiler.scala:15)
at play.scalasupport.ScalaPlugin$$anonfun$templates$1.apply(ScalaPlugin.scala:178)
at play.scalasupport.ScalaPlugin$$anonfun$templates$1.apply(ScalaPlugin.scala:177)
at play.scalasupport.ScalaPlugin.templates(ScalaPlugin.scala:177)
at play.scalasupport.ScalaPlugin.update(ScalaPlugin.scala:195)
at play.scalasupport.ScalaPlugin.detectClassesChange(ScalaPlugin.scala:107)
at play.plugins.PluginCollection.detectClassesChange(PluginCollection.java:358)
at play.Play.detectChanges(Play.java:594)
at play.Invoker$Invocation.init(Invoker.java:186)
... 1 more

it turns out that scala-library-2.9.0-1.jar is included as a dependency for neo4j...
every time I run play dependencies it will be downloaded into the lib folder, after I delete it from the folder, it works without problem (so far I just have code for starting and shutting down of the DB).

The Cypher Query language depends on Scala. We will update that dependency to 2.9.1 for the 1.5 release.

Related

JOOQ integration with R2dbc driver for PostgreSQL

I am trying to setup correctly JOOQ with Spring Boot project which uses reactive stack based on r2dbc driver for Postgres DB. I came across quite few problems and at the very end "hopefully" I stucked on following error:
Caused by: java.lang.NoSuchMethodError: 'org.jooq.DSLContext org.jooq.impl.DSL.using(io.r2dbc.spi.ConnectionFactory)
here is most relevant part of my build.gradle:
compileOnly("org.jooq:jooq:3.17.5")
compileOnly("org.jooq:jooq-codegen:3.17.5")
compileOnly("org.jooq:jooq-meta-extensions:3.17.5")
implementation("org.jooq:jooq-meta:3.17.5")
implementation("org.jooq:jooq-kotlin-coroutines:3.17.5")
implementation("org.jooq:jooq-kotlin:3.17.5")
runtimeOnly("io.r2dbc:r2dbc-postgresql:0.8.13.RELEASE")
runtimeOnly("io.r2dbc:r2dbc-spi:1.0.0.RELEASE")
runtimeOnly("io.r2dbc:r2dbc-pool:1.0.0.RELEASE")
runtimeOnly("org.postgresql:postgresql:42.5.0")
I am running Spring Boot 2.7.5
The cause of exception is from runtime and is in part of the code:
private val dsl = DSL.using(
ConnectionFactories.get(
ConnectionFactoryOptions
.parse(databaseConfig.url)
.mutate()
.option(USER, databaseConfig.username)
.option(PASSWORD, databaseConfig.password)
.build()
)
)
databaseConfig.url: r2dbc:pool:postgresql://localhost:5432/test
Mostly I have tried changing the dependencies versions as I don't have any other valid idea at the moment.
You're using:
compileOnly("org.jooq:jooq:3.17.5")
This means you're using the latest jOOQ version only at compile time (which is why your code compiles), but at runtime, you're using Spring Boot's jOOQ version, which is older. Try changing that to compile, or add it also to the implementation section

Cannot instantiate router [consistent-hashing-pool], defined in [/IO-DNS/inet-address] error in akka/spray

I am trying create a sample akka/spray project from here
While the code compiles successfully in sbt, sbt run command throws me an error
java.lang.IllegalArgumentException: Cannot instantiate router [consistent-hashin
g-pool], defined in [/IO-DNS/inet-address], make sure it extends [akka.routing.R
outerConfig] and has constructor with [com.typesafe.config.Config] parameter
the same code compiles and runs successfully in IntelliJ Idea IDE.
EDIT:
Scala version I am using is 2.11 and related libraries
Akka version. 2.4.0 and spray 1.3.3
Yes , this is occurred if you are using akka version below 2.5.4 , because for lower version need to configure routing , Please follow the link http://doc.akka.io/docs/akka/2.4.0/scala/routing.html for routing in lower version . If you can upgrade the version onwards 2.5.4 then no need to routing.

NoSuchMethod exception in Flink when using dataset with custom object array

I have a problem with Flink
java.lang.NoSuchMethodError: org.apache.flink.api.java.typeutils.ObjectArrayTypeInfo.getInfoFor(Lorg/apache/flink/api/common/typeinfo/TypeInformation;)Lorg/apache/flink/api/java/typeutils/ObjectArrayTypeInfo;
at LowLevel.FlinkImplementation.FlinkImplementation$$anon$6.<init>(FlinkImplementation.scala:28)
at LowLevel.FlinkImplementation.FlinkImplementation.<init>(FlinkImplementation.scala:28)
at IRLogic.GmqlServer.<init>(GmqlServer.scala:15)
at it.polimi.App$.main(App.scala:20)
at it.polimi.App.main(App.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
...
the line with the problem is this one
implicit val regionTypeInformation =
api.scala.createTypeInformation[FlinkDataTypes.FlinkRegionType]
in the FlinkRegionType I have an Array of custom object
I developed the app with the maven plugin in the IDE and everything is working good, but when I move to the version I downloaded from the website I get the error above
I am using Flink 0.9
I was thinking that some library may be missing but I am using maven for handling everything. Moreover running through the code of ObjectArrayTypeInfo.java it doesn't seem to be the problem
A NoSuchMethodError commonly indicates a version mismatch between the libraries a Flink program was compiled with and the system the program is executed on. Especially if the same code works in an IDE setup where compile and execution libraries are the same.
In such case, you should check the version of the Flink dependencies, for example in the Maven POM file.

How to fix akka version compatibility issues?

I was thinking of using spark and redis together with SBT.
It runs fine if I comment out the spark dependency, if I include the spark dependency I get:
Exception in thread "main" java.lang.NoSuchMethodError: akka.actor.ActorSystem.dispatcher()Lscala/concurrent/ExecutionContextExecutor;
at redis.RedisClientActorLike.<init>(Redis.scala:31)
at redis.RedisClient.<init>(Redis.scala:69)
I have no issues when I do not include "redisscala". When I do include redisscala, then I get weird errors about Akka.
How do I get around this?
It appears that those versions of Spark and rediscala are using incompatible versions of Akka. Spark 1.1.0 is using Akka 2.2.3, and rediscala 1.3.1 is using Akka 2.3.4. There are some changes between Akka 2.2.x and 2.3.x that are causing issues, and your project currently has both as transient dependencies.
You either need to downgrade rediscala to 1.2 (which uses Akka 2.2.x), or upgrade Spark to 1.2-snapshot (which uses Akka 2.3.x).

Error while including casbah dependencies

I am facing problem in getting started with casabah to integrate scala and mongoDb. I am using Spring Tool Suite(STS) and imported the following jar files :
spring-data-mongodb-1.6.0.RELEASE.jar
com.mongodb.jar
casbah-commons_2.10-2.7.2.jar
casbah-query_2.10-2.7.2.jar
joda-time-2.1.jar
slf4j-api-1.7.7.jar
casbah-gridfs_2.10-2.5.0.jar
scalaj-collection_2.10-1.4.jar
slf4j-simple-1.7.7.jar
casbah-core_2.10-2.7.2.jar
mongo-2.10.0.jar
mongo-java-driver-2.10.0.jar
However, I get an error.
Error:Description Resource Path Location Type bad symbolic reference. A signature in Implicits.class refers to type Cursor in package com.mongodb which is not available. It may be completely missing from the current classpath, or the version on the classpath might be incompatible with the version used when compiling Implicits.class.
I read a couple of posts that says the problem is with the version in mongo-java-driver so i tried with mongo-java-driver-2.10.1.jar as well , But it was still giving me an error.
Could someone please help me resolve this error??
Thanks a lot in advance!!!
It looks like its a dependency issue. Casbah is built upon a fixed version of the Mongo Java driver so is reliant on a specific binary compatible version.
The Casbah version numbers should all be the same - above you mainly have Casbah 2.7.2 but the gridfs version is wrong: casbah-gridfs_2.10-2.5.0.jar.
Also, Casbah 2.7.2 relies on version 2.12.2 of the Mongo Java Driver, however, the latest version of Casbah is 2.7.3 which relies on version 2.12.3 of the Mongo Java Driver.
To make this simpler there is a all dependencies jar for Casbah that includes the latest version of the java driver and all the other relevant dependencies. Alternatively, the pom file should point all dependent packages which declare their dependencies. (As Casbah is split into sub packages the casbah-commons pom has all the external dependencies listed).