how to use titan from java

89 views
Skip to first unread message

alexander

unread,
Oct 2, 2016, 7:53:42 AM10/2/16
to Aurelius
Hi all,

besides running groovy scripts via ttans gremlin.sh -e, I'd like to execute groovy/gremlin from within java.

I read the docs and found e.g. Using-Gremlin-through-Groovy

I already have netbeans IDE with groovy (their own plugin) working and can execute java / groovy mixed code.

What I can't do is

import com.thinkaurelius.titan.core.TitanFactory
or
Gremlin.load

because netbeans groovy of course does not provide any gremlin / titan specifics.

=> I guess I would need to add the titan stuff to the projects used libraries in netbeans.
I'm not sure what would be the best way to do so: as individual jar's, the complete folder in
titan-titan10/lib or some other approach...

Any hint on that?

Thx
Alexander



alexander

unread,
Oct 2, 2016, 10:12:01 AM10/2/16
to Aurelius
Adding all titan10/lib/*.jar as used libraries seems to work (at first I added the folder itself, wich did not work).

Now my gremlin/groovy code compiles and runs, opens the existing db and fetches correct graph-data from there.
It is the exact same code, I used with gremlin.sh -e. Thats fine. So no need for Gremlin.load?

However, I get lot of output like the following:
15:59:33.107 [main] DEBUG c.t.t.diskstorage.lucene.LuceneIndex - Configured Lucene to use base directory [/home/alexp/dsesRuns/runDir7/titan/conf/../db/searchindex]
15:59:33.118 [main] INFO  c.t.titan.diskstorage.Backend - Initiated backend operations thread pool of size 8
15:59:33.122 [main] DEBUG c.t.t.d.b.BerkeleyJEStoreManager - Opened database titan_ids
15:59:32.876 [main] DEBUG c.t.t.d.b.BerkeleyJEStoreManager - Opened database system_properties
java.lang.Throwable: null
    at com.thinkaurelius.titan.diskstorage.berkeleyje.BerkeleyJEStoreManager.openDatabase(BerkeleyJEStoreManager.java:172) [titan-berkeleyje-1.0.1-SNAPSHOT.jar:na]
    at com.thinkaurelius.titan.diskstorage.berkeleyje.BerkeleyJEStoreManager.openDatabase(BerkeleyJEStoreManager.java:34) [titan-berkeleyje-1.0.1-SNAPSHOT.jar:na]
    at com.thinkaurelius.titan.diskstorage.keycolumnvalue.keyvalue.OrderedKeyValueStoreManagerAdapter.openDatabase(OrderedKeyValueStoreManagerAdapter.java:76) [titan-core-1.0.1-SNAPSHOT.jar:na]
    at com.thinkaurelius.titan.diskstorage.keycolumnvalue.keyvalue.OrderedKeyValueStoreManagerAdapter.openDatabase(OrderedKeyValueStoreManagerAdapter.java:69) [titan-core-1.0.1-SNAPSHOT.jar:na]
    at com.thinkaurelius.titan.diskstorage.keycolumnvalue.keyvalue.OrderedKeyValueStoreManagerAdapter.openDatabase(OrderedKeyValueStoreManagerAdapter.java:25) [titan-core-1.0.1-SNAPSHOT.jar:na]
    at com.thinkaurelius.titan.diskstorage.Backend.getStandaloneGlobalConfiguration(Backend.java:449) [titan-core-1.0.1-SNAPSHOT.jar:na]
    at com.thinkaurelius.titan.graphdb.configuration.GraphDatabaseConfiguration.<init>(GraphDatabaseConfiguration.java:1322) [titan-core-1.0.1-SNAPSHOT.jar:na]
    at com.thinkaurelius.titan.core.TitanFactory.open(TitanFactory.java:94) [titan-core-1.0.1-SNAPSHOT.jar:na]
    at com.thinkaurelius.titan.core.TitanFactory.open(TitanFactory.java:62) [titan-core-1.0.1-SNAPSHOT.jar:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_101]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_101]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_101]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_101]
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) [groovy-2.4.1-indy.jar:2.4.1]
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324) [groovy-2.4.1-indy.jar:2.4.1]
    at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite$StaticMetaMethodSiteNoUnwrap.invoke(StaticMetaMethodSite.java:130) [groovy-2.4.1-indy.jar:2.4.1]
    at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.call(StaticMetaMethodSite.java:88) [groovy-2.4.1-indy.jar:2.4.1]
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45) [groovy-2.4.1-indy.jar:2.4.1]
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:110) [groovy-2.4.1-indy.jar:2.4.1]
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:122) [groovy-2.4.1-indy.jar:2.4.1]
    at dses.dcerebra.groovy.resultGraphs.SimGraph.main(SimGraph.groovy:36) [classes/:na]

There a many lines wit [main] DEBUG ... which is some information about what happened.
But there is some java.lang.Throwable: null stuff.
I'm not sure about these - do I have a problem there?

Thx
Alexander

Jason Plurad

unread,
Oct 2, 2016, 12:42:35 PM10/2/16
to Aurelius
Try this starter example https://github.com/pluradj/titan-tp3-java-example

With Java 8, the need for Groovy to use Gremlin is minimal.
--
You received this message because you are subscribed to the Google Groups "Aurelius" group.
To unsubscribe from this group and stop receiving emails from it, send an email to aureliusgraph...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/aureliusgraphs/73950ba6-20c1-429e-aee9-618a1f0273f0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

alexander

unread,
Oct 11, 2016, 6:06:54 AM10/11/16
to Aurelius
thx!
Reply all
Reply to author
Forward
0 new messages