-1

I'm a beginner with Titan Graph Database and I'm just trying to create a simple titan graph in a particular path using eclipse.Initially , setting the titan configurations followed by creating two vertices and an edge. This is the code i had given :

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.");
        }
    }

But when i run the java, i am getting IllegalArgumentException as below.

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

I have added the dependencies for titan, cassandra. Please anyone guide me with this issue.

Details of dependencies added in pom.xml is as below :

<!-- 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>
sabi
  • 29
  • 1
  • 1
  • 5

1 Answers1

2

Your pom.xml has a lot of stuff going on in it that doesn't need to be there. The most damaging thing is probably the fact that you have three different version of titan in there. If you are using "cassandra" then all you should need is this:

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

You should also remove all those added dependencies as they will likely invite version conflict. For your simple example, I have a feeling that you only really need the above <dependency> entry (plus maybe the "logging" dependency, depending on which one you are using if not already coming as a transitive dependency from titan).

stephen mallette
  • 45,298
  • 5
  • 67
  • 135
  • hello,thanking you for ur response.i have changed the dependencies to ..com.thinkaurelius.titantitan-core0.5.4com.thinkaurelius.titantitan-cassandra0.5.4com.tinkerpop.blueprintsblueprints-core2.6.0 but now getting error ...Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/cassandra/exceptions/ConfigurationException – sabi May 12 '15 at 08:21
  • you still probably have more complexity that you need. here's a sample repo that should work out of the box (even it includes blueprints which should come as a transitive dependency and probably doesn't need to be there, but it should get you started): https://github.com/dkuppitz/titan-sandbox – stephen mallette May 12 '15 at 09:57
  • Hi ,I referred to the link u mentioned above,tried to the SandBox.java by including the dependencies of blueprints-core and titan-all ,yet getting error in the code. `TitanFactory.build() .set("storage.backend", "cassandra") .set("storage.hostname", "localhost").open(); ` Error details as : **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** wht did i miss ? – sabi May 12 '15 at 11:28
  • works fine for me - is cassandra installed and running? btw, i've asked the owner of that repo to bump titan to 0.5.4 and drop the blueprints pom entry (doesn't need to be there). – stephen mallette May 12 '15 at 11:51
  • Thanks , the code run successfully now..but i cannot view any files generated in the path `TITAN_DB = "target/tmp/titan"` a per given in the code..where is the db files generated? – sabi May 13 '15 at 07:01
  • as you are running cassandra separately you should see your `cassandra.yaml` file to determine the location of your data files. – stephen mallette May 13 '15 at 10:11