Class BytecodeUtil missing in TinkerPop releases?

134 views
Skip to first unread message

Florian Grieskamp

unread,
Jan 20, 2020, 2:01:48 AM1/20/20
to Gremlin-users
Hi everybody!

While developing a Java application which connects to a Gremlin server, I found something that looks like a bug in newer releases of TinkerPop. Below is my MWE:

GraphTraversalSource g = AnonymousTraversalSource.traversal().withRemote(propertiesFile);
long vertices = g.V().count().next();


When importing TinkerPop 3.4.1 as a dependency via maven, everything works as expected and I get the number of vertices in the graph.
Although, versions 3.4.2 to 3.4.4 show me the following error raised in the second line given above:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/tinkerpop/gremlin/process/traversal/util/BytecodeUtil
    at org
.apache.tinkerpop.gremlin.driver.remote.DriverRemoteConnection.getRequestOptions(DriverRemoteConnection.java:230)
    at org
.apache.tinkerpop.gremlin.driver.remote.DriverRemoteConnection.submitAsync(DriverRemoteConnection.java:223)
    at org
.apache.tinkerpop.gremlin.process.remote.traversal.step.map.RemoteStep.promise(RemoteStep.java:89)
    at org
.apache.tinkerpop.gremlin.process.remote.traversal.step.map.RemoteStep.processNextStart(RemoteStep.java:65)
    at org
.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.next(AbstractStep.java:128)
    at org
.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.next(AbstractStep.java:38)
    at org
.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal.next(DefaultTraversal.java:200)
    at
my.app.App.initializeConnection(App.java:39)
    at
my.app.App.main(App.java:22)
Caused by: java.lang.ClassNotFoundException: org.apache.tinkerpop.gremlin.process.traversal.util.BytecodeUtil
    at java
.net.UddRLClassLoader.findClass(URLClassLoader.java:382)
    at java
.lang.ClassLoader.loadClass(ClassLoader.java:418)
    at sun
.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
    at java
.lang.ClassLoader.loadClass(ClassLoader.java:351)
   
... 9 more


Digging into the commit history of TinkerPop gave me the following insights:
  • The class BytecodeUtil.java was added in Version 3.4.2 (which is the first version that fails for me)
  • This class is not included in any release
I checked this by extracting the provided .jar file and searching for the compiled BytecodeUtil.class file. I can confirm this file is not included within the library.

Can any of you reproduce this error or give me advice on how to fix it?

Stephen Mallette

unread,
Jan 20, 2020, 7:04:57 AM1/20/20
to gremli...@googlegroups.com
BytecodeUtil is present in the source at 3.4.4 (and is still present going forward):


I happened to have Gremlin Console 3.4.4 installed locally and unpacked the gremlin-core jar - I do in fact find that class present there. I even downloaded the artifact directly from maven central:


unpacked it and found BytecodeUtil present. Is it possible that you aren't referencing gremlin-core somehow and only gremlin-driver? gremlin-driver depends on gremlin-core so if you're using maven/gradle/etc it should automatically grab that dependency. 

--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/144c2f82-da44-403f-ba2a-21117864be80%40googlegroups.com.
Message has been deleted
Message has been deleted

Florian Grieskamp

unread,
Jan 20, 2020, 8:01:32 AM1/20/20
to Gremlin-users
Thanks for your reply! I tried explicitly importing gremlin-core and it works!

I'm still curious why maven does not do so by default.

This does not work:

...
<dependency>
  
<groupId>org.apache.tinkerpop</groupId>
  <artifactId>gremlin-driver</
artifactId>
  
<version>3.4.4</version>
</
dependency>
...

But this works:

...
<dependency>
  
<groupId>org.apache.tinkerpop</groupId>
  <artifactId>gremlin-core</
artifactId>
  
<version>3.4.4</version>
</
dependency>
<dependency>
  <groupId>org.apache.tinkerpop</groupId>
  
<artifactId>gremlin-driver</artifactId>
  
<version>3.4.4</version>
</dependency>
...

Stephen Mallette

unread,
Jan 20, 2020, 8:18:18 AM1/20/20
to gremli...@googlegroups.com
you really shouldn't have to do that. i'm not sure why gremlin-core wouldn't just behave as a transitive dependency. you didn't state when you received that error but if it was related to your IDE building the project it's possible that you simply don't have something configured right in there. if you received that error as a result of "mvn clean install" however i'm at a loss to explain why you are seeing that behavior.

--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.

Florian Grieskamp

unread,
Jan 20, 2020, 9:49:36 AM1/20/20
to Gremlin-users
It seems this is rather an issue i have with maven than with gremlin. I just can't get maven to work with transitive dependencies.
To make sure it's not an issue with an IDE, i reproduced the error with the following commands:

mvn clean install
mvn
exec:java -Dexec.mainClass=my.app.App

Again, everything works fine with versions prior to 3.4.2 or if i explicitly list gremlin-core as a dependency.
Newer versions of gremlin-driver without explicit gremlin-core declaration produce the same error as seen in the initial post.

Florian Grieskamp

unread,
Jan 20, 2020, 9:59:26 AM1/20/20
to Gremlin-users
This is interesting: The output of mvn dependency:tree does not show gremlin-core as a dependency of gremlin-driver:

[INFO] Scanning for projects...
[INFO]
[INFO] -----------------------------< my.app:app >-----------------------------
[INFO] Building app 0.0.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ app ---
[INFO] my.app:app:jar:0.0.1
[INFO] +- junit:junit:jar:4.12:test
[INFO] |  \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- org.janusgraph:janusgraph-core:jar:0.4.0:compile
[INFO] |  +- org.apache.tinkerpop:gremlin-core:jar:3.4.1:compile
[INFO] |  |  +- org.apache.tinkerpop:gremlin-shaded:jar:3.4.1:compile
[INFO] |  |  +- org.yaml:snakeyaml:jar:1.15:compile
[INFO] |  |  +- org.javatuples:javatuples:jar:1.2:compile
[INFO] |  |  +- com.jcabi:jcabi-manifests:jar:1.1:compile
[INFO] |  |  |  \- com.jcabi:jcabi-log:jar:0.14:compile
[INFO] |  |  +- com.squareup:javapoet:jar:1.8.0:compile
[INFO] |  |  +- net.objecthunter:exp4j:jar:0.4.8:compile
[INFO] |  |  \- org.slf4j:jcl-over-slf4j:jar:1.7.25:compile
[INFO] |  +- org.apache.tinkerpop:gremlin-groovy:jar:3.4.1:compile
[INFO] |  |  +- org.apache.ivy:ivy:jar:2.3.0:compile
[INFO] |  |  +- org.codehaus.groovy:groovy-groovysh:jar:indy:2.5.6:compile
[INFO] |  |  |  +- org.codehaus.groovy:groovy-cli-picocli:jar:2.5.6:compile
[INFO] |  |  |  |  \- info.picocli:picocli:jar:3.9.2:compile
[INFO] |  |  |  +- org.codehaus.groovy:groovy-console:jar:2.5.6:compile
[INFO] |  |  |  |  +- org.codehaus.groovy:groovy-swing:jar:2.5.6:compile
[INFO] |  |  |  |  \- org.codehaus.groovy:groovy-templates:jar:2.5.6:compile
[INFO] |  |  |  |     \- org.codehaus.groovy:groovy-xml:jar:2.5.6:compile
[INFO] |  |  |  \- jline:jline:jar:2.14.6:compile
[INFO] |  |  +- org.codehaus.groovy:groovy-jsr223:jar:indy:2.5.6:compile
[INFO] |  |  +- org.mindrot:jbcrypt:jar:0.4:compile
[INFO] |  |  \- com.github.ben-manes.caffeine:caffeine:jar:2.3.1:compile
[INFO] |  +- org.apache.tinkerpop:tinkergraph-gremlin:jar:3.4.1:compile
[INFO] |  +- org.glassfish:javax.json:jar:1.0:compile
[INFO] |  +- io.dropwizard.metrics:metrics-core:jar:3.2.2:compile
[INFO] |  +- io.dropwizard.metrics:metrics-ganglia:jar:3.2.2:compile
[INFO] |  |  \- info.ganglia.gmetric4j:gmetric4j:jar:1.0.7:compile
[INFO] |  +- io.dropwizard.metrics:metrics-graphite:jar:3.2.2:compile
[INFO] |  +- org.reflections:reflections:jar:0.9.9-RC1:compile
[INFO] |  |  +- org.javassist:javassist:jar:3.16.1-GA:compile
[INFO] |  |  \- dom4j:dom4j:jar:1.6.1:compile
[INFO] |  |     \- xml-apis:xml-apis:jar:1.0.b2:compile
[INFO] |  +- org.locationtech.spatial4j:spatial4j:jar:0.7:compile
[INFO] |  +- org.locationtech.jts:jts-core:jar:1.15.0:compile
[INFO] |  +- commons-collections:commons-collections:jar:3.2.2:compile
[INFO] |  +- commons-configuration:commons-configuration:jar:1.10:compile
[INFO] |  |  +- commons-lang:commons-lang:jar:2.6:compile
[INFO] |  |  \- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] |  +- commons-io:commons-io:jar:2.3:compile
[INFO] |  +- commons-codec:commons-codec:jar:1.7:compile
[INFO] |  +- com.google.guava:guava:jar:18.0:compile
[INFO] |  +- com.carrotsearch:hppc:jar:0.7.1:compile
[INFO] |  +- com.github.stephenc.high-scale-lib:high-scale-lib:jar:1.1.4:compile
[INFO] |  +- com.google.code.findbugs:jsr305:jar:3.0.0:compile
[INFO] |  +- org.noggit:noggit:jar:0.6:compile
[INFO] |  \- org.apache.commons:commons-text:jar:1.0:compile
[INFO] +- org.apache.tinkerpop:gremlin-driver:jar:3.4.4:compile  <===== gremlin-driver is listed here but it does not show gremlin-core as a dependency
[INFO] |  +- io.netty:netty-all:jar:4.1.36.Final:compile
[INFO] |  +- org.codehaus.groovy:groovy:jar:indy:2.5.7:compile
[INFO] |  +- org.codehaus.groovy:groovy-json:jar:indy:2.5.7:compile
[INFO] |  \- org.apache.commons:commons-lang3:jar:3.8.1:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.7.5:compile
[INFO] \- org.slf4j:slf4j-log4j12:jar:1.7.5:compile
[INFO]    \- log4j:log4j:jar:1.2.17:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.787 s
[INFO] Finished at: 2020-01-20T15:54:33+01:00
[INFO] ------------------------------------------------------------------------

Florian Grieskamp

unread,
Jan 21, 2020, 2:47:15 AM1/21/20
to Gremlin-users
Update: I (kind of) found the problem that caused this behaviour.
The dependency tree shows gremlin-core as a dependency of JanusGraph, which I also imported in my pom.xml. Just out of curiosity I tried changing the order of my dependency list to import gremlin-driver first and then janusgraph.
Turns out it works! 

janusgraph-core:0:4:0 requires gremlin-core:3.4.1. At the time gremlin-driver:3.4.4 is loaded, gremlin-core:3.4.1 is already imported as a dependency of JanusGraph and this seems to satisfy gremlin-driver's dependency list.
By the way, this is also the reason why I was unable to find the class BytecodeUtil in my generated jar. It's simply not included in the gremlin-core version that was imported.

For me, this only raises the next question: Doesn't gremlin-driver depend on the latest version of gremlin-core?

Stephen Mallette

unread,
Jan 21, 2020, 6:19:55 AM1/21/20
to gremli...@googlegroups.com
You have a jar conflict and the i believe that it does not resolve itself in a deterministic fashion, so even ordering of dependencies isn't a real fix. I highly recommend the use of the maven enforcer plugin as it will identify all such problems so that you are forced to resolve them:


Anyway, the best fix here would be to switch to gremlin-driver 3.4.1 as that is the version JanusGraph 0.4.0 depends on. The alternative would be to use a maven dependency <exclusion> on janusgraph-core for gremlin-core which will allow the gremlin-core from 3.4.4 to be used definitively. Typically you should bind your TinkerPop version to the version your graph supports for the best results as those versions have been validated to work with one another via numerous test suites in TinkerPop and the host graph provider, so changing your gremlin-driver version to 3.4.1 is probably the best option in this case. If you must use 3.4.4 for some reason, please be sure to read the upgrade notes for all TinkerPop versions you're skipping to be aware of possible incompatibilities so that you can steer clear of them.

--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages