【问题标题】:How to connect Java with Titan with embedded Cassandra如何使用嵌入式 Cassandra 将 Java 与 Titan 连接起来
【发布时间】:2015-11-12 19:20:53
【问题描述】:

我安装了titan-cassandra-0.4.4,可以完美运行cassandra和gremlin(本地节点)。

我想用Java测试一个算法,所以我需要将Java连接到titan。 我的 pom 是:

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

我的代码是:

    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);

在最后一行,错误是:

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

我首先启动 cassandra,然后是 titan gremlin.sh,最后运行 java 代码。不知道是不是遗漏了什么?

提前致谢!

【问题讨论】:

    标签: java cassandra titan


    【解决方案1】:

    您应该包含titan-casssandra 的依赖项。

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

    另外请注意,如果您刚刚开始使用 Titan,0.4.4 版本已经过时了。 Titan 1.0 于 2015 年 9 月发布。您可以在http://titandb.io 找到更多信息

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-10-01
      • 1970-01-01
      • 2016-10-02
      • 2018-08-13
      • 2013-08-11
      • 1970-01-01
      • 2014-07-10
      • 1970-01-01
      相关资源
      最近更新 更多