Script16.groovy: 2: unable to resolve class StandardJanusGraph


hadoopmarc@...
 

Hi Vinayak,

If I understand it right (did not test it), you have to use two gremlin consoles:

  1. Use one gremlin console to connect to your server and use ConfiguredGraphFactory. This will manage which graphs are available to to other gremlin console instances.
  2. Use the second gremlin console to connect to the graph that you activated in the first console. In the second console you can use a sessioned remote connection to do any imports you need to run your script remotely.
Best wishes,    Marc


Vinayak Bali
 

Hi Marc,

The same code works for JanusGraphFactory but not for ConfiguredGraphFactory. I investigated issue further. For ConfiguredGraphFactory we establish remote connection using following commands:
bin/gremlin.sh
:remote connect tinkerpop.server conf/remote.yaml session
:remote console

The imports are not working after establishing remote connection. Imports works without remote connection. How can we solve this problem ???

Thanks & Regards,
Vinayak

On Tue, 9 Mar 2021, 9:30 pm , <hadoopmarc@...> wrote:
Hi Vinayak,

I only replayed exactly your imports, not the rest of your code. Downloading dependencies may depend on the grape configs of your system, see:

https://docs.janusgraph.org/basics/server/#using-tinkerpop-gremlin-server-with-janusgraph
https://tinkerpop.apache.org/docs/current/reference/#gremlin-applications

Best wishes,    Marc


hadoopmarc@...
 

Hi Vinayak,

I only replayed exactly your imports, not the rest of your code. Downloading dependencies may depend on the grape configs of your system, see:

https://docs.janusgraph.org/basics/server/#using-tinkerpop-gremlin-server-with-janusgraph
https://tinkerpop.apache.org/docs/current/reference/#gremlin-applications

Best wishes,    Marc


Vinayak Bali
 

Hi Marc,

If possible please share the code used, let me check if it can be used to modify my code.

Thanks & Regards,
Vinayak

On Tue, 9 Mar 2021, 12:54 pm , <hadoopmarc@...> wrote:
Hi Vinayak,

When I replayed your imports I got the same error, but when I tried again it worked. I guess the delay for downloading dependencies was too high and second time the cache could be used.

Best wishes,    Marc


hadoopmarc@...
 

Hi Vinayak,

When I replayed your imports I got the same error, but when I tried again it worked. I guess the delay for downloading dependencies was too high and second time the cache could be used.

Best wishes,    Marc


Vinayak Bali
 

Hi Marc,

Explicitly, imported StandardJanusGraph using the following import command which is not working:
org.janusgraph.graphdb.database.StandardJanusGraph

Tried Graph approach too, it throws the following error:

Script158.groovy: 1: unable to resolve class LinkedBlockingQueue
 @ line 1, column 1.
   class WaitingQueue<E> extends LinkedBlockingQueue<E>
   ^

1 error
Type ':help' or ':h' for help.
Display stack trace? [yN]y
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script158.groovy: 1: unable to resolve class LinkedBlockingQueue
 @ line 1, column 1.
   class WaitingQueue<E> extends LinkedBlockingQueue<E>
   ^

1 error

at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:311)
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:980)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:647)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:596)
at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:390)
at groovy.lang.GroovyClassLoader.access$300(GroovyClassLoader.java:89)
at groovy.lang.GroovyClassLoader$5.provide(GroovyClassLoader.java:330)
at groovy.lang.GroovyClassLoader$5.provide(GroovyClassLoader.java:327)
at org.codehaus.groovy.runtime.memoize.ConcurrentCommonCache.getAndPut(ConcurrentCommonCache.java:147)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:325)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:309)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:251)
at org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine$GroovyCacheLoader.lambda$load$0(GremlinGroovyScriptEngine.java:819)
at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1604)
at java.util.concurrent.CompletableFuture.asyncSupplyStage(CompletableFuture.java:1618)
at java.util.concurrent.CompletableFuture.supplyAsync(CompletableFuture.java:1843)
at org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine$GroovyCacheLoader.load(GremlinGroovyScriptEngine.java:817)
at org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine$GroovyCacheLoader.load(GremlinGroovyScriptEngine.java:812)
at com.github.benmanes.caffeine.cache.BoundedLocalCache$BoundedLocalLoadingCache.lambda$new$0(BoundedLocalCache.java:3117)
at com.github.benmanes.caffeine.cache.LocalCache.lambda$statsAware$0(LocalCache.java:144)
at com.github.benmanes.caffeine.cache.BoundedLocalCache.lambda$doComputeIfAbsent$16(BoundedLocalCache.java:1968)
at java.util.concurrent.ConcurrentHashMap.compute(ConcurrentHashMap.java:1853)
at com.github.benmanes.caffeine.cache.BoundedLocalCache.doComputeIfAbsent(BoundedLocalCache.java:1966)
at com.github.benmanes.caffeine.cache.BoundedLocalCache.computeIfAbsent(BoundedLocalCache.java:1949)
at com.github.benmanes.caffeine.cache.LocalCache.computeIfAbsent(LocalCache.java:113)
at com.github.benmanes.caffeine.cache.LocalLoadingCache.get(LocalLoadingCache.java:67)
at org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine.getScriptClass(GremlinGroovyScriptEngine.java:567)
at org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine.eval(GremlinGroovyScriptEngine.java:374)
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:233)
at org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor.lambda$eval$0(GremlinExecutor.java:267)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

All the import statements are:
import org.janusgraph.core.ConfiguredGraphFactory
//import org.janusgraph.core.Cardinality
//import org.apache.tinkerpop.gremlin.structure.Vertex

import java.util.concurrent.Executors
import java.util.concurrent.LinkedBlockingQueue
import java.util.concurrent.ThreadPoolExecutor
import java.util.concurrent.TimeUnit

import org.janusgraph.graphdb.database.StandardJanusGraph
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource
import com.opencsv.CSVReaderBuilder
import com.opencsv.CSVReader
import com.opencsv.enums.CSVReaderNullFieldIndicator

Based on your experience, please suggest an approach using which I can solve the issue.

Thanks & Regards,
Vinayak

On Mon, Mar 8, 2021 at 5:50 PM <hadoopmarc@...> wrote:
Hi Vinayak,

What may confuse you is that the gremlin console does a lot of under the hood imports, but it doesn't import all janusgraph classes. So, you can solve this in two ways:
  1. Preferred: rather use the underlying interface for specifiying the type, so line 3 private Graph graph;
  2. Optional: do an explicit import of StandardJanusGraph
gremlin> StandardJanusGraph
No such property: StandardJanusGraph for class: groovysh_evaluate
Type ':help' or ':h' for help.
Display stack trace? [yN]n
gremlin> Graph
==>interface org.apache.tinkerpop.gremlin.structure.Graph


Best wishes,    Marc


hadoopmarc@...
 

Hi Vinayak,

What may confuse you is that the gremlin console does a lot of under the hood imports, but it doesn't import all janusgraph classes. So, you can solve this in two ways:
  1. Preferred: rather use the underlying interface for specifiying the type, so line 3 private Graph graph;
  2. Optional: do an explicit import of StandardJanusGraph
gremlin> StandardJanusGraph
No such property: StandardJanusGraph for class: groovysh_evaluate
Type ':help' or ':h' for help.
Display stack trace? [yN]n
gremlin> Graph
==>interface org.apache.tinkerpop.gremlin.structure.Graph


Best wishes,    Marc


Vinayak Bali
 

Hi All,

Using a batch processing script to load the data into the graph. With JanusGraphFactory the scripts were working as expected. Now the same code is not working with ConfiguredGraphFactory. The error is as follows:

Script16.groovy: 2: unable to resolve class StandardJanusGraph
 @ line 2, column 3.
     private StandardJanusGraph graph;
     ^

Script16.groovy: 7: unable to resolve class StandardJanusGraph
 @ line 7, column 22.
     public CsvImporter(StandardJanusGraph graph, int batchNumber, List csvRecords
                        ^

2 errors
Type ':help' or ':h' for help.
Display stack trace? [yN]y
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script16.groovy: 2: unable to resolve class StandardJanusGraph
 @ line 2, column 3.
     private StandardJanusGraph graph;
     ^

Script16.groovy: 7: unable to resolve class StandardJanusGraph
 @ line 7, column 22.
     public CsvImporter(StandardJanusGraph graph, int batchNumber, List csvRecords
                        ^

2 errors

at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:311)
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:980)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:647)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:596)
at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:390)
at groovy.lang.GroovyClassLoader.access$300(GroovyClassLoader.java:89)
at groovy.lang.GroovyClassLoader$5.provide(GroovyClassLoader.java:330)
at groovy.lang.GroovyClassLoader$5.provide(GroovyClassLoader.java:327)
at org.codehaus.groovy.runtime.memoize.ConcurrentCommonCache.getAndPut(ConcurrentCommonCache.java:147)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:325)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:309)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:251)
at org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine$GroovyCacheLoader.lambda$load$0(GremlinGroovyScriptEngine.java:819)
at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1604)
at java.util.concurrent.CompletableFuture.asyncSupplyStage(CompletableFuture.java:1618)
at java.util.concurrent.CompletableFuture.supplyAsync(CompletableFuture.java:1843)
at org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine$GroovyCacheLoader.load(GremlinGroovyScriptEngine.java:817)
at org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine$GroovyCacheLoader.load(GremlinGroovyScriptEngine.java:812)
at com.github.benmanes.caffeine.cache.BoundedLocalCache$BoundedLocalLoadingCache.lambda$new$0(BoundedLocalCache.java:3117)
at com.github.benmanes.caffeine.cache.LocalCache.lambda$statsAware$0(LocalCache.java:144)
at com.github.benmanes.caffeine.cache.BoundedLocalCache.lambda$doComputeIfAbsent$16(BoundedLocalCache.java:1968)
at java.util.concurrent.ConcurrentHashMap.compute(ConcurrentHashMap.java:1892)
at com.github.benmanes.caffeine.cache.BoundedLocalCache.doComputeIfAbsent(BoundedLocalCache.java:1966)
at com.github.benmanes.caffeine.cache.BoundedLocalCache.computeIfAbsent(BoundedLocalCache.java:1949)
at com.github.benmanes.caffeine.cache.LocalCache.computeIfAbsent(LocalCache.java:113)
at com.github.benmanes.caffeine.cache.LocalLoadingCache.get(LocalLoadingCache.java:67)
at org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine.getScriptClass(GremlinGroovyScriptEngine.java:567)
at org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine.eval(GremlinGroovyScriptEngine.java:374)
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:233)
at org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor.lambda$eval$0(GremlinExecutor.java:267)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

A small part of the code:

class CsvImporter implements Runnable {

  private StandardJanusGraph graph;
  private int batchNumber;
  private List csvRecords;
  private int lastRecord;
  private Closure processor;

  public CsvImporter(StandardJanusGraph graph, int batchNumber, List csvRecords
    , int lastRecord, Closure processor) {

    this.graph = graph;
    this.batchNumber = batchNumber
    this.csvRecords = csvRecords
    this.lastRecord = lastRecord
    this.processor = processor
  }

Initial code to access graph using JanusGraphFactory
graph = ctx.graph = graph = JanusGraphFactory.open('/home/fusionops/janusgraph-full-0.5.2/conf/graph1.properties')
Updated code to access graph using ConfiguredGraphFactory
graph = ctx.graph = graph = ConfiguredGraphFactory.open("merck_graph_explorer_demo")

Thanks & Regards,
Vinayak