3.7.0 gremlin-groovy console with multi-line statements

270 views
Skip to first unread message

pdsway

unread,
Sep 21, 2023, 5:32:54 PM9/21/23
to Gremlin-users
With TP 3.6.5 (groovy 2.x) the groovy console works as expected for both local and remote connections.

I can create a statement like:
if (1 == 1)  {
  // do some stuff
}

and the console handles it.

With 3.7.0 (groovy 4.x) this works locally, but if I connect to a remote gremlin-server (any version), I get a syntax error after entering the first line ("if (1 == 1) {".

Any fix for this?

Ken Hu

unread,
Sep 22, 2023, 8:46:53 PM9/22/23
to Gremlin-users
Can you provide some more details about what you are doing and the error you are getting from the console?

I tried the following in the 3.7.0 console and it worked fine.

gremlin> g = traversal().withRemote(DriverRemoteConnection.using("localhost", 8182))
==>graphtraversalsource[emptygraph[empty], standard]
gremlin> if (1==1) {
......1>     g.addV()
......2> }
==>v[0]

pdsway

unread,
Sep 22, 2023, 9:10:48 PM9/22/23
to Gremlin-users
ok thanks, run gremlin.bat (windows) to start console where i can run any groovy.

then i connect to my (local) gremlin server with:
:rem connect tinkerpop.server conf/remote.yaml
:rem console

then multi-line groovy fails.

Ken Hu

unread,
Oct 3, 2023, 2:45:03 PM10/3/23
to Gremlin-users
I looked into this a little more and it seems to be an issue with how we handle incomplete lines for the remote console. The 3.7.0 remote console will send every line to the server even if it is incomplete. I'll make a Jira for this issue so that we will follow-up on it. Right now, there doesn't seem to be a workaround for the 3.7.0 console.

pdsway

unread,
Oct 3, 2023, 2:52:32 PM10/3/23
to Gremlin-users
TYVM Ken, that helps us greatly.

-Paul

Ken Hu

unread,
Oct 3, 2023, 3:55:12 PM10/3/23
to Gremlin-users

pdsway

unread,
Dec 6, 2023, 12:54:14 PM12/6/23
to Gremlin-users
Ken...

I tested TP 3.7.1 (w JanusGraph) and a new Gremlin console problem...

console command ":remote console" no longer toggles to the remote connection.
it basically has no effect and you must prefix all remote commands with ":>"

Thanks,
-Paul

pdsway

unread,
Dec 6, 2023, 1:26:23 PM12/6/23
to Gremlin-users
Actually it seems multi-line statements DO go remote, but something simple like "Gremlin.version()" always executes locally.]
So accessing objects seems to ignore the state of ":remote console".
I'll reply if I find more.

Ken Hu

unread,
Dec 6, 2023, 2:32:25 PM12/6/23
to Gremlin-users
Can you try to find a repro case with gremlin-server? That would eliminate more variables and help to figure out what is happening.

pdsway

unread,
Dec 7, 2023, 12:22:04 PM12/7/23
to Gremlin-users

Yes, I was able to test a little more and it seems an issue with JanusGraph imports, since Tinkergraph imports seem to work (local and remote).
JanusGraph methods only execute locally, so perhaps a JanusGraph specific problem.

I added JanusGraph imports to vanilla Gremlin 3.7.1 client then connected to my local JanusGraph (compiled with TP 3.7.1) and I can retrieve properties from JG objects (ie JanusGraphFactory) but I cannot execute a method on those objects (error is as if I was executing in local context), however the TinkerGraph methods (also imported/plugin) do work remotely.  Strange one.

pdsway

unread,
Dec 19, 2023, 2:35:50 PM12/19/23
to Gremlin-users
Ken...

  First, a simple bug in gremlin console, easily repeated.
1) NPE starting gremlin-console (3.7.0+) when file "ext\plugins.txt" has 1+ empty lines.

2) I got JanusGraph 1.0 / TP 3.7.1 working properly by removing the "JanusGraphGremlinPlugin" line from file "ext\plugins.txt" which seems to force gremlin console to send all JanusGraph specific commands (ie. JanusGraph.version();) to the remote.  If the plugin is configured, the gremlin-console will only execute local (except if forced like  ":> JanusGraph.version();").  Obviously this isn't a fix, just a work-around.

Thanks,
-Paul

Ken Hu

unread,
Jan 4, 2024, 1:00:47 PMJan 4
to Gremlin-users
Thanks for the detailed information. I'll take a look into this later and see what can be done.

Ken Hu

unread,
Jan 18, 2024, 1:12:19 PMJan 18
to Gremlin-users
I took a closer look into this and this is what I found.

1) I got this same error and am tracking it at https://issues.apache.org/jira/browse/TINKERPOP-3038

2) I haven't been able to reproduce this behavior with a slightly modified setup. I added the JanusGraph imports to a vanilla gremlin-console that I connected to a GremlinServer. I saw the following:
         \,,,/
         (o o)
-----oOOo-(3)-oOOo-----
plugin activated: tinkerpop.server
plugin activated: tinkerpop.utilities
plugin activated: tinkerpop.tinkergraph
plugin activated: janusgraph.imports
gremlin> JanusGraph.version()
==>1.0.0
gremlin> :remote connect tinkerpop.server conf/remote.yaml
==>Configured localhost/127.0.0.1:8182
gremlin> :remote console
==>All scripts will now be sent to Gremlin Server - [localhost/127.0.0.1:8182] - type ':remote console' to return to local mode
gremlin> JanusGraph.version()
org.apache.tinkerpop.gremlin.driver.exception.ResponseException: No such property: JanusGraph for class: Script3
at org.apache.tinkerpop.gremlin.driver.Handler$GremlinResponseHandler.channelRead0(Handler.java:246)
at org.apache.tinkerpop.gremlin.driver.Handler$GremlinResponseHandler.channelRead0(Handler.java:201)
at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:99)
...
No such property: JanusGraph for class: Script3
Type ':help' or ':h' for help.

Since I was connected to a GremlinServer and not JanusGraphServer, I expected to see the missing property which confirms that it is indeed sending the "JanusGraph.version()" command remotely.

Am I doing something different from the scenario that you used that encountered this error?

pdsway

unread,
Jan 23, 2024, 5:35:57 PMJan 23
to Gremlin-users
Thanks Ken...

I rechecked using my latest JG (essentially the 1.0.1 tag/branch) and the problem is still there.

I start with a JG 1.0+ server (with TinkerPop 3.7.0+)

using the same JG 1.0+ binaries (or any Gremlin binary 3.7.0+ with JanusGraphGremlinPlugin plugin)
1) ext/plugins.txt WITH JanusGraphGremlinPlugin (janusgraph.imports)
2) run gremlin client/console
3) connect to JG server: ":remote connect tinkerpop.server conf/remote-objects.yaml session" (uses GraphBinary with serializeResultToString = true)
4) run ":remote console" (to send commands to the remote by default)
5) run "JanusGraphFactory.getGraphNames();"
6) error "Gremlin Server must be configured to use the JanusGraphManager"
    (this is because the console executed the local method which of course has no Gremlin/Janus server)
7) run ":> JanusGraphFactory.getGraphNames();" and I get the graph names as expected.

My current work-around is to simply remove "JanusGraphGremlinPlugin" from "plugins.txt" and the gremlin console executes remotely like it should.
\
For some reason, when the gremlin groovy console finds the "JanusGraphFactory" locally it executes it, ignoring the ":remote console" state.

I also tested with an old Janus 0.6.2 client (TinkerPop 1.21.0) and oddly that client worked as expected.
So it seems an issue with a TinkerPop 3.7.0+ client to a TinkerPop 3.7.0+ server.

To add the Janus plugin (to a gremlin binary), I just drop the Janus core and driver jar files to the gremlin lib.

Ken Hu

unread,
Jan 24, 2024, 1:13:03 PMJan 24
to Gremlin-users
Thanks again for the detailed information. I've reproduced this issue now and it is being tracked by https://issues.apache.org/jira/browse/TINKERPOP-3040
Reply all
Reply to author
Forward
0 new messages