Titan IllegalArgumentException:无法实例化实现:com.thinkaurelius.titan.diskstorage.cassandra.astyanax.AstyanaxStoreManager

时间:2015-05-11 12:30:06

标签: eclipse maven cassandra titan blueprint

我是Titan Graph数据库的初学者,我只想尝试使用eclipse在特定路径中创建一个简单的titan图。最初,设置titan配置,然后创建两个顶点和一个边。 这是我给出的代码:

public class TitanGraphDemo {
        private static final String TITAN_DB = "target/tmp/titan";
        private static final Logger logger = LoggerFactory.getLogger(TitanGraphDemo.class);
        public static void init() {
            Configuration  conf = new BaseConfiguration();
            conf.setProperty("storage.directory", TITAN_DB);
            conf.setProperty("storage.backend","cassandra");
            conf.setProperty("storage.hostname","127.0.0.1");
            conf.setProperty("storage.port","9160");
            TitanGraph graph = TitanFactory.open(conf);

            Vertex rash = graph.addVertex(null);
            rash.setProperty("userId", 1);
            rash.setProperty("username", "rash");
            rash.setProperty("firstName", "Rahul");
            rash.setProperty("lastName", "Chaudhary");
            rash.setProperty("birthday", 101);

            Vertex honey = graph.addVertex(null);
            honey.setProperty("userId", 2);
            honey.setProperty("username", "honey");
            honey.setProperty("firstName", "Honey");
            honey.setProperty("lastName", "Anant");
            honey.setProperty("birthday", 201);

            Edge frnd = graph.addEdge(null, rash, honey, "FRIEND");
            frnd.setProperty("since", 2011);
            graph.commit();
            logger.info("Titan graph loaded successfully.");
        }
    }

但是当我运行java时,我得到的IllegalArgumentException如下所示。

Exception in thread "main" java.lang.IllegalArgumentException: Could not instantiate implementation: com.thinkaurelius.titan.diskstorage.cassandra.astyanax.AstyanaxStoreManager
    at com.thinkaurelius.titan.util.system.ConfigurationUtil.instantiate(ConfigurationUtil.java:55)
    at com.thinkaurelius.titan.diskstorage.Backend.getImplementationClass(Backend.java:421)
    at com.thinkaurelius.titan.diskstorage.Backend.getStorageManager(Backend.java:361)
    at com.thinkaurelius.titan.graphdb.configuration.GraphDatabaseConfiguration.<init>(GraphDatabaseConfiguration.java:1275)
    at com.thinkaurelius.titan.core.TitanFactory.open(TitanFactory.java:93)
    at com.thinkaurelius.titan.core.TitanFactory.open(TitanFactory.java:73)
    at titan.TitanGraphDemo.init(TitanGraphDemo.java:37)
    at titan.TitanGraphDemo.main(TitanGraphDemo.java:113)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.thinkaurelius.titan.util.system.ConfigurationUtil.instantiate(ConfigurationUtil.java:44)
    ... 7 more
Caused by: java.lang.NoSuchMethodError: com.netflix.astyanax.impl.AstyanaxConfigurationImpl.setTargetCassandraVersion(Ljava/lang/String;)Lcom/netflix/astyanax/impl/AstyanaxConfigurationImpl;
    at com.thinkaurelius.titan.diskstorage.cassandra.astyanax.AstyanaxStoreManager.getContextBuilder(AstyanaxStoreManager.java:474)
    at com.thinkaurelius.titan.diskstorage.cassandra.astyanax.AstyanaxStoreManager.<init>(AstyanaxStoreManager.java:267)
    ... 12 more

我添加了titan,cassandra的依赖项。请有人指导我解决这个问题。

pom.xml中添加的依赖项的详细信息如下:

<!-- Libraries -->
    <dependencies>
        <!-- TinkerPop -->
        <dependency>
            <groupId>com.tinkerpop.blueprints</groupId>
            <artifactId>blueprints-core</artifactId>
            <version>2.6.0</version>
        </dependency>
        <dependency>
            <groupId>com.tinkerpop.blueprints</groupId>
            <artifactId>blueprints-test</artifactId>
            <version>2.6.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.tinkerpop.gremlin</groupId>
            <artifactId>gremlin-groovy</artifactId>
            <version>2.1.0</version>
            <exclusions>
                <exclusion>
                    <artifactId>gossip</artifactId>
                    <groupId>org.sonatype.gossip</groupId>
                </exclusion>
            </exclusions>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.tinkerpop.rexster</groupId>
            <artifactId>rexster-core</artifactId>
            <version>2.1.0</version>
        </dependency>
        <!-- Utility -->
        <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
            <version>3.2.1</version>
        </dependency>
        <dependency>
            <groupId>commons-configuration</groupId>
            <artifactId>commons-configuration</artifactId>
            <version>1.6</version>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.0.1</version>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>12.0</version>
        </dependency>
        <dependency>
            <groupId>colt</groupId>
            <artifactId>colt</artifactId>
            <version>1.2.0</version>
        </dependency>
        <dependency>
            <groupId>com.googlecode</groupId>
            <artifactId>kryo</artifactId>
            <version>1.04</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cassandra</groupId>
            <artifactId>cassandra-all</artifactId>
            <version>1.2.5</version>
        </dependency>
        <dependency>
          <groupId>org.objenesis</groupId>
          <artifactId>objenesis</artifactId>
          <version>2.1</version>
        </dependency>
        <dependency>
            <groupId>com.netflix.astyanax</groupId>
            <artifactId>astyanax</artifactId>
            <version>1.0.6</version>
        </dependency>

        <!-- Logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.6</version>
        </dependency>
       <!--  <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.6.1</version>
        </dependency> -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.16</version>
        </dependency>


        <!-- Storage backends -->
        <!-- HBase -->
        <dependency>
            <groupId>org.apache.hbase</groupId>
            <artifactId>hbase</artifactId>
            <!-- Update the hadoop-core artifact version when you update this -->
            <version>0.94.1</version>
            <exclusions>
                <exclusion>
                    <artifactId>avro</artifactId>
                    <groupId>org.apache.avro</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>jruby-complete</artifactId>
                    <groupId>org.jruby</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-core</artifactId>
            <!-- Update the hbase artifact version when you update this -->
            <version>1.0.3</version>
        </dependency>
        <!-- Cassandra -->
       <dependency>
            <groupId>commons-pool</groupId>
            <artifactId>commons-pool</artifactId>
            <version>1.5.5</version>
        </dependency>
        <!-- BerkeleyDB -->
        <dependency>
            <groupId>com.sleepycat</groupId>
            <artifactId>je</artifactId>
            <version>5.0.58</version>
        </dependency>


        <!-- Test Dependencies -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <version>1.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.thinkaurelius.titan</groupId>
            <artifactId>titan-core</artifactId>
            <version>0.5.4</version>
        </dependency>
        <dependency>
            <groupId>com.thinkaurelius.titan</groupId>
            <artifactId>titan-cassandra</artifactId>
            <version>0.5.0</version>
        </dependency>
         <dependency>
            <groupId>com.thinkaurelius.titan</groupId>
            <artifactId>titan-all</artifactId>
            <version>0.5.0-M1</version>
        </dependency> 

        <dependency>
            <groupId>com.datastax.cassandra</groupId>
            <artifactId>cassandra-driver-core</artifactId>
            <version>2.0.0-beta2</version>
        </dependency>
    </dependencies>

1 个答案:

答案 0 :(得分:2)

你的pom.xml里面有很多东西,不需要在那里。最具破坏性的事情可能就是你有三种不同版本的泰坦。如果您正在使用&#34; cassandra&#34;那你需要的就是:

<dependency>
  <groupId>com.thinkaurelius.titan</groupId>
  <artifactId>titan-cassandra</artifactId>
  <version>0.5.4</version>
</dependency>

您还应该删除所有这些添加的依赖项,因为它们可能会引发版本冲突。对于您的简单示例,我感觉您只需要上面的<dependency>条目(加上可能是&#34;日志记录&#34;依赖项,具体取决于您使用的是哪一个,如果尚未作为传递来自泰坦的依赖)。

相关问题