You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@metamodel.apache.org by "Kasper Sørensen (JIRA)" <ji...@apache.org> on 2018/05/01 03:50:00 UTC

[jira] [Commented] (METAMODEL-1182) java.lang.IllegalStateException while creatin Neo4jDataContext

    [ https://issues.apache.org/jira/browse/METAMODEL-1182?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16459424#comment-16459424 ] 

Kasper Sørensen commented on METAMODEL-1182:
--------------------------------------------

Thanks for your feedback and bug report. I honestly don't know what the issue is here, but just wanted to give feedback on your first question: The code you wrote seems valid, and it shouldn't fail like this. But I will say that the query you wrote won't work either since you have to write the query in MetaModel's SQL dialect, not Neo4j's query language. MetaModel translates the SQL to whatever the underlying database uses. If you want to use Neo4j's language, then using a straight integration without MetaModel is probably going to be a better fit for you.

> java.lang.IllegalStateException while creatin Neo4jDataContext
> --------------------------------------------------------------
>
>                 Key: METAMODEL-1182
>                 URL: https://issues.apache.org/jira/browse/METAMODEL-1182
>             Project: Apache MetaModel
>          Issue Type: Bug
>    Affects Versions: 5.0.0
>            Reporter: Mahesh Abnave
>            Priority: Major
>              Labels: patch
>
> 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:
> {code:java}
> Neo4jDataContext neoData = new  Neo4jDataContext("localhost", 7474, "neo4j", "password");
> System.out.println(neoData.executeQuery("MATCH (n:Logs) RETURN n LIMIT 25"));
> {code}
> {{But I was getting following exception:}}
> {code:java}
> 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
> {code}
> 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|https://github.com/apache/metamodel/blob/master/neo4j/src/main/java/org/apache/metamodel/neo4j/Neo4jDataContext.java#L163]. But for some random label, getAllNodesPerLabel() called on [line 171|https://github.com/apache/metamodel/blob/master/neo4j/src/main/java/org/apache/metamodel/neo4j/Neo4jDataContext.java#L171] 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.
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)