readonly traversal exception in program, but works from gremlin remote console

137 views
Skip to first unread message

Lee Mitchell

unread,
Jul 28, 2016, 12:58:46 PM7/28/16
to Gremlin-users
I would greatly appreciate guidance/ideas/thoughts anybody can share on how I might resolve this error message from my program's websocket connection to a gremlin server that is scripted to provide a readonly traversal.

response message:
org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep cannot be cast to org.apache.tinkerpop.gremlin.process.traversal.step.ByModulating


The query 
g.E().valueMap(true).toList()

works fine from a gremlin console remote connection, but not my program.

Many Thanks, Lee

------ tldr; more details below ------

I have a database(neo4j) that I have started gremlin server(3.2.0-incubating) to manage, instructing it to provide a readonly traversal (g)

globals << [g : graph.traversal(GraphTraversalSource.build().with(ReadOnlyStrategy.instance()))]

via this script

// An example of an initialization script that can be configured to run in Gremlin Server.
// Functions defined here will go into global cache and will not be removed from there
// unless there is a reset of the ScriptEngine.
def addItUp(x, y) { x + y }

// an init script that returns a Map allows explicit setting of global bindings.
def globals = [:]

// defines a sample LifeCycleHook that prints some output to the Gremlin Server console.
// note that the name of the key in the "global" map is unimportant.
globals << [hook : [
  onStartUp: { ctx ->
    ctx.logger.info("Executed once at startup of Gremlin Server.")
  },
  onShutDown: { ctx ->
    ctx.logger.info("Executed once at shutdown of Gremlin Server.")
  }
] as LifeCycleHook]

// define the default ReadOnly TraversalSource to bind queries to - this one will be named "g".
globals << [g : graph.traversal(GraphTraversalSource.build().with(ReadOnlyStrategy.instance()))]



After I connect via gremlin console (3.2.0-incubating) and remote into the gremlin server,

it is indeed read only, given this command / result

gremlin> g.E(0).property('anything',1)
The provided traversal has a mutating step and thus is not read only: AddPropertyStep({key=[anything], value=[1]})
Display stack trace? [yN]



But when I try to read the edges via a progam websocket connection using this query:

            const string query = "g.E().by(valueMap(true)).toList()";

The gremlin server response has
code:597
message:"org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep cannot be cast to org.apache.tinkerpop.gremlin.process.traversal.step.ByModulating"


Yet, from my remote gremlin console, the query works


gremlin> g.E().valueMap(true).toList()
==>{nullArcDescription=self-loop-on-nullNode, label=nullArc, id=0}
==>{takePcs=40, givePcs=40, vdest=888, label=flowArc, id=1}
==>{takePcs=40, givePcs=40, vdest=888, label=flowArc, id=2}
==>{takePcs=60, givePcs=60, vdest=888, label=ovFlowArc, id=3}
==>{takePcs=40, givePcs=40, vdest=888, label=ovFlowArc, id=4}
==>{takePcs=40, givePcs=40, vdest=888, label=ovFlowArc, id=5}
==>{takePcs=20, givePcs=20, vdest=888, label=flowArc, id=6}
==>{takePcs=60, givePcs=60, vdest=888, label=flowArc, id=7}
==>{takePcs=100, givePcs=100, vdest=888, label=endDlvArc, id=8}
==>{takePcs=100, givePcs=100, vdest=888, label=dlvArc, id=9}




Lee Mitchell

unread,
Jul 28, 2016, 1:56:21 PM7/28/16
to Gremlin-users
The solution was to change my program query to

g.E().valueMap(true).toList()

Instead of 
g.E().by(valueMap(true)).toList()
Reply all
Reply to author
Forward
0 new messages