简体   繁体   English

如何使用嵌入式Cassandra将Java与Titan连接起来

[英]How to connect Java with Titan with embedded Cassandra

I installed titan-cassandra-0.4.4 , and I can run cassandra and gremlin perfectly (The local node). 我安装了titan-cassandra-0.4.4 ,我可以完美地运行cassandra和gremlin(本地节点)。

I want to test an algorithm in Java, so I need to connect Java to titan. 我想用Java测试算法,所以我需要将Java连接到titan。 My pom is: 我的pom是:

    <dependency>
        <groupId>com.thinkaurelius.titan</groupId>
        <artifactId>titan-core</artifactId>
        <version>0.4.4</version>
    </dependency>

My codes are: 我的代码是:

    BaseConfiguration baseConfiguration = new BaseConfiguration();
    baseConfiguration.setProperty("storage.backend", "cassandra");
    baseConfiguration.setProperty("storage.hostname", "127.0.0.1");
    baseConfiguration.setProperty("storage.tablename","test");

    TitanGraph titanGraph = TitanFactory.open(baseConfiguration);

In the last line, the error is: 在最后一行中,错误是:

Exception in thread "main" java.lang.NoClassDefFoundError: com/netflix/astyanax/connectionpool/exceptions/ConnectionException
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.thinkaurelius.titan.diskstorage.Backend.getStorageManager(Backend.java:202)
at com.thinkaurelius.titan.diskstorage.Backend.<init>(Backend.java:97)
at com.thinkaurelius.titan.graphdb.configuration.GraphDatabaseConfiguration.getBackend(GraphDatabaseConfiguration.java:398)
at com.thinkaurelius.titan.graphdb.database.StandardTitanGraph.<init>(StandardTitanGraph.java:78)
at com.thinkaurelius.titan.core.TitanFactory.open(TitanFactory.java:60)
at Connecting.main(Connecting.java:20)
Caused by: java.lang.ClassNotFoundException: com.netflix.astyanax.connectionpool.exceptions.ConnectionException
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 8 more

I first start the cassandra, then titan gremlin.sh, and run the java code at last. 我首先启动cassandra,然后启动titan gremlin.sh,最后运行java代码。 I do not know if I was missing something? 我不知道我是否遗失了什么?

Thanks in advance! 提前致谢!

You should include a dependency for titan-casssandra . 你应该为titan-casssandra包含一个依赖titan-casssandra

    <dependency>
        <groupId>com.thinkaurelius.titan</groupId>
        <artifactId>titan-casssandra</artifactId>
        <version>0.4.4</version>
    </dependency>

Also note if you're just getting started with Titan, version 0.4.4 is far out of date. 另请注意,如果您刚开始使用Titan,0.4.4版本已经过时了。 Titan 1.0 was released in September 2015. You can find more information at http://titandb.io Titan 1.0于2015年9月发布。您可以在http://titandb.io上找到更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM