Comments (21)
See PR #56
from anormcypher.
Certainly. The working-in-progress code is checked in on the akka-stream
branch. Quite a few tests are failing, but the main idea is there for a reactive parser of json streams. I haven't been able to find time to complete it, having quite a few commitments that I've promised to meet. So any help would be great appreciated.
Thanks!
from anormcypher.
AnormCypher depends on Play WS 2.4. This is probably another library incompatibility issue.
If you are using Play Framework 2.5, you can provide an implicit instance of the framework's WSClient. But if you are writing a standalone app, you're better off just declaring the anormcypher dependency, which should pull in the right Play WSClient for you.
from anormcypher.
I switched to play-ws_2.11-2.4.6 and it doesn't throw there. It's OK, just thought I'll use the latest version.
from anormcypher.
Awesome. We never had http client library issues till Play 2.4. That's when we switched to using Play's WS client. It looks like this will be another hurdle for 2.5 also.
I will leave this ticket open for a while in case people run into the same problem.
Thanks for the detailed report.
from anormcypher.
Is support for Play 2.5 planned?
from anormcypher.
I'm not sure how helpful this is, but it seems the issue might be related to the Json.reads
macro.
In version 0.8.1
java.lang.NoSuchMethodError: play.api.libs.functional.syntax.package$.functionalCanBuildApplicative(Lplay/api/libs/functional/Applicative;)Lplay/api/libs/functional/FunctionalCanBuild;
at org.anormcypher.Neo4jREST$.<init>(Neo4jREST.scala:141)
at org.anormcypher.Neo4jREST$.<clinit>(Neo4jREST.scala)
Where line 141 is:
implicit val cypherRESTResultReads = Json.reads[CypherRESTResult]
In verison 0.9.0
java.lang.NoClassDefFoundError: Could not initialize class org.anormcypher.Neo4jREST$
at org.anormcypher.Neo4jREST.streamAutocommit(Neo4jREST.scala:40)
at org.anormcypher.Neo4jConnection$class.execute(Neo4jConnection.scala:15)
at org.anormcypher.Neo4jREST.execute(Neo4jREST.scala:9)
at org.anormcypher.Neo4jTransaction$$anon$1.cypher(Neo4jConnection.scala:64)
at org.anormcypher.CypherStatement.async(AnormCypher.scala:358)
at org.anormcypher.CypherStatement.apply(AnormCypher.scala:355)
Where line 40 is:
val source = req.withBody(Json.toJson(wrapCypher(stmt))).stream()
Actually the first error in 0.9.0 is the same as 0.8.1:
java.lang.NoSuchMethodError: play.api.libs.functional.syntax.package$.functionalCanBuildApplicative(Lplay/api/libs/functional/Applicative;)Lplay/api/libs/functional/FunctionalCanBuild;
at org.anormcypher.Neo4jREST$.<init>(Neo4jREST.scala:192)
at org.anormcypher.Neo4jREST$.<clinit>(Neo4jREST.scala)
At line: implicit val cypherRESTResultReads = Json.reads[CypherRESTResult]
Also, it looks like the method was moved in this commit:
playframework/playframework@f6935a4
from anormcypher.
Thanks! It's definitely helpful. It appears that the library incompatibility is not just in WS but at a deeper layer in the Play functional api. This definitely neuters the idea of detecting at runtime which version of Play is running and then using reflection to invoke the right methods.
And to your other question, yes, there will certainly be a build for Play 2.5, but probably not in the next quarter or so. One question is whether we are going to support both 2.4 and 2.5 or drop the build for 2.4. Since it's very likely there is going to be source incompatibility, we will have to maintain 2 different branches, one to support each version. That may not be too big a deal if there isn't much development activity. But there are still some issues that need to be ironed out with the new transaction code, e.g. automatic sequencing of async code in the transactional block and nested transaction. I don't think there are many users that need these right now, but they are definitely functional holes. Opening up a 2.5 branch before these are solved completely, or at least decided to be non-supported features, is a bit too zealous for me :)
from anormcypher.
Yeah it looks like 2.4 and 2.5 are pretty different.
I started played around with building AnormCypher with 2.5.
It seems like the main issue is "The main theme of Play 2.5 has been moving from Playβs iteratee-based asynchronous IO API to Akka Streams." and Neo4jREST /Neo4jStream make heavy use of Enumerator's.
With a few small changes I got it to compile...but I had to comment out Neo4jStream.parse()
and return null. If a Source[ByteString,_]
can be converted to a Enumerator[Array[Byte]]
I think AnormCypher can work with 2.5 with minimal changes.
The main change was in Neo4jREST:
override def streamAutocommit(stmt: CypherStatement)(implicit ec: ExecutionContext) = {
val req = request(AutocommitEndpoint).withMethod(POST)
val source = req.withBody(Json.toJson(wrapCypher(stmt))).stream()
Enumerator.flatten(source map { case resp:StreamedResponse =>
Neo4jStream.parse2(resp.body)
})
}
I'm planning to see if parse2
can call the original parse method after converting Source[ByteString,_]
to Enumerator[Array[Byte]]
.
For the 2.5 version of AnormCypher do you think its preferable to convert the iteratee-based code to use Akka Streams?
https://www.playframework.com/documentation/2.5.x/StreamsMigration25
from anormcypher.
Definitely send a PR when you are done, and we can put that on an experimental Play_2_5 branch.
I think it's a little too early to switch to Akka Streams for 2.5. When the 3.0 series is released, that might be a good time, though with the past history, APIs do often break from one minor release to the next with Play. So even with a major release, the chance is not negligible that we will keep spinning with updates. But at least it will be less than right now.
On the other hand, the migration implementation is usually pretty good with Play. I think just using their recommended Source.fromPublisher(Streams.enumeratorToPublisher(...))
should suffice for the support for now.
Thanks!
from anormcypher.
I almost forgot, the streaming JSON parser of the REST response, while not super-difficult, is not trivial. it'd be interesting to see if it's any easier to write using the Rx Stream API. And we don't have to wait till 3.0 before starting working with that.
Cheers!
from anormcypher.
As mentioned in the discussion around PR #56, because the iteratee-based parser uses combinators from the iteratee-extras library, which itself depends on Play 2.4, to be able to run inside Play 2.5, we'd need to completely rewrite the streaming json parser using Akka Stream. At first glance this does not appear to be particularly challenging (though things could change once work starts), so this will be the approach to take.
After supporting 2.5, development will have to stop for Play 2.4 because of source code incompatibility. I'd like to get the transaction part a little more solid on the 2.4 side first.
from anormcypher.
We're in luck. There is some new code JsonFraming
in Akka Stream that provides self-contained json bits, in ByteString frames. It's not in the 2.4 branch, but can be borrowed for use here until it's in an official release. With that piece in place it should be pretty straight forward to finish this issue.
from anormcypher.
Is there any planned release or workaround for Play 2.5? Something we can help maybe?
from anormcypher.
@Kai-Chen What is "com.sorrentocorp" %% "streaming-json-parser" % "0.1.1-SNAPSHOT"
?(unresolvable dependency)
from anormcypher.
Sorry about that ... that's located here https://github.com/kai-chen/streaming-json-parser, a temporary holding place for potentially reusable code.
from anormcypher.
jroper/play-iteratees-extras#12 has been finally merged. Would be great to get Play 2.5 support through PR #56 before the akka-stream based implementation is ready.
from anormcypher.
Thanks, Martin!
I just re-opened PR 56, but it's got conflict.
Do you mind sending an update?
I will take a look this weekend, if time allows.
from anormcypher.
The PR is merged and released as 0.10.0.
Thanks Martin!
Eve's published the jar last night, and it should be available now.
from anormcypher.
Sent from my BE2015 using FastHub
from anormcypher.
The following code produces error:
import akka.actor.ActorSystem
import akka.stream.ActorMaterializer
import org.anormcypher.Neo4jREST
import play.api.libs.json.Json
import play.api.libs.ws.ning
object importTraces extends App {
implicit val system = ActorSystem("neo4j-system")
implicit val materializer = ActorMaterializer()
implicit val wsclient = ning.NingWSClient()
implicit val connection = Neo4jREST("localhost", 7474, "/db/data/", "guest", "neo4j")
}
Exception in thread "main" java.lang.NoSuchMethodError: play.api.libs.functional.syntax.package$.functionalCanBuildApplicative(Lplay/api/libs/functional/Applicative;)Lplay/api/libs/functional/FunctionalCanBuild;
at org.anormcypher.Neo4jREST$.(Neo4jREST.scala:141)
at org.anormcypher.Neo4jREST$.(Neo4jREST.scala)
at importTraces$.delayedEndpoint$importTraces$1(importTraces.scala:12)
at importTraces$delayedInit$body.apply(importTraces.scala:7)
at scala.Function0$class.apply$mcV$sp(Function0.scala:34)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App$$anonfun$main$1.apply(App.scala:76)
at scala.App$$anonfun$main$1.apply(App.scala:76)
at scala.collection.immutable.List.foreach(List.scala:381)
at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:35)
at scala.App$class.main(App.scala:76)
at importTraces$.main(importTraces.scala:7)
at importTraces.main(importTraces.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
i use
"com.typesafe.play" % "play-ws_2.11" % "2.5.0"
"org.anormcypher" %% "anormcypher" % "0.8.1"
from anormcypher.
Related Issues (20)
- Add Play 2.5 support HOT 2
- With Neo4j 3.0.x, Cypher query returning 2 results per record (one with actual value, one with null) HOT 7
- Generating Dynamic CQL in AnormCypher HOT 2
- Parse meta data returned from neo4j 3.0 tx endpoint
- Use macro to ensure that all code within the withTx block is executed sequentially HOT 1
- A number of the tests are failing with an exception HOT 5
- AnormCypher fails resolving dependencies HOT 5
- Neo4jREST.mapFormat doesn't support JsNull values HOT 5
- neo4j-jdbc HOT 3
- Async transaction support
- Cannot query data with neo4j 3.2.1 HOT 1
- initialCommands in console
- Query performance regressions since v0.7.1 HOT 2
- repo.anormcypher.org down HOT 3
- Clustering
- Release version for 2.12 HOT 1
- NingWSClient requires akka.stream.Materializer, and is deprecated
- Mirror packages on Maven Central HOT 1
- [email protected]
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from anormcypher.