Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
5.0.0
-
None
Description
I was trying Apache Metamodel for the first time. I did not find much examples online. So I referred following links:
- https://cwiki.apache.org/confluence/display/METAMODEL/Query+object%2C+the+QueryBuilder+API+and+Query+parsing
- https://cwiki.apache.org/confluence/display/METAMODEL/DataContext
- https://github.com/apache/metamodel/tree/master/neo4j/src/main/java/org/apache/metamodel/neo4j
- https://github.com/apache/metamodel/blob/master/neo4j/src/main/java/org/apache/metamodel/neo4j/Neo4jDataContext.java
Guessed what I should be doing and I wrote first simple code:
Neo4jDataContext neoData = new Neo4jDataContext("localhost", 7474, "neo4j", "password"); System.out.println(neoData.executeQuery("MATCH (n:Logs) RETURN n LIMIT 25"));
But I was getting following exception:
Exception in thread "main" java.lang.IllegalStateException: org.json.JSONException: A JSONArray text must start with '[' at character 0 at org.apache.metamodel.neo4j.Neo4jDataContext.getAllNodesPerLabel(Neo4jDataContext.java:277) at org.apache.metamodel.neo4j.Neo4jDataContext.detectTableDefs(Neo4jDataContext.java:171) at org.apache.metamodel.neo4j.Neo4jDataContext.<init>(Neo4jDataContext.java:97) at com.digitate.ignio.ApacheMetamodelExp.ApacheMetamodelPoc.main(ApacheMetamodelPoc.java:14) Caused by: org.json.JSONException: A JSONArray text must start with '[' at character 0 at org.json.JSONTokener.syntaxError(JSONTokener.java:410) at org.json.JSONArray.<init>(JSONArray.java:113) at org.json.JSONArray.<init>(JSONArray.java:157) at org.apache.metamodel.neo4j.Neo4jDataContext.getAllNodesPerLabel(Neo4jDataContext.java:269) ... 3 more
Am I correct with the two line code? I mean is it supposed to work? I debugged in eclipse. I realized that inside Neo4jDataContext() constructor, call to detectTableDefs() is made. Inside detectTableDefs(), the labelsJsonArray is getting populated correctly on line 163. But for some random label, getAllNodesPerLabel() called on line 171 throws above exception. By "some random label" , I mean that for some labels, getAllNodesPerLabel() executes successfully on line 171, but suddenly it fails for some labels. I am unable to pin point for which labels / which characteristics of labels exception is occurring.