0

I set up the Hector API for Cassandra Database in Eclipse. I got errors about SLF4J [some logging utility]. I've spent the last [almost] 2 hours debugging errors with it. After importing the packages, I get

Exception in thread "main" java.lang.ExceptionInInitializerError at org.slf4j.LoggerFactory.bind(LoggerFactory.java:128) at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:108) at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:279) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:252) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:265) at me.prettyprint.cassandra.service.AbstractCluster.(AbstractCluster.java:44) at me.prettyprint.cassandra.service.ThriftCluster.(ThriftCluster.java:21) at me.prettyprint.hector.api.factory.HFactory.createCluster(HFactory.java:196) at me.prettyprint.hector.api.factory.HFactory.getOrCreateCluster(HFactory.java:143) at me.prettyprint.hector.api.factory.HFactory.getOrCreateCluster(HFactory.java:132) at CassandraInterface.main(CassandraInterface.java:7) Caused by: java.lang.UnsupportedOperationException: This code should have never made it into the jar at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:63) at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:44) ... 11 more

Is there any Cassandra database API that I can just drop into my Eclipse project and begin using out of the box, without having to install, configure, and debug additional 3rd-party software?

Also: I don't have Maven installed. The best thing would be a single JAR file or folder of JAR files/java sources.

EDIT: I have the Hector API installed and my program compiles without errors, but now I get a runtime error

Exception in thread "main" java.lang.NoSuchMethodError: org.apache.thrift.meta_data.FieldValueMetaData.<init>(BZ)V
    at org.apache.cassandra.thrift.ColumnParent.<clinit>(ColumnParent.java:128)
    at me.prettyprint.cassandra.service.template.AbstractColumnFamilyTemplate.<init>(AbstractColumnFamilyTemplate.java:63)
    at me.prettyprint.cassandra.service.template.ColumnFamilyTemplate.<init>(ColumnFamilyTemplate.java:39)
    at me.prettyprint.cassandra.service.template.ThriftColumnFamilyTemplate.<init>(ThriftColumnFamilyTemplate.java:38)
    at CassandraInterface.main(CassandraInterface.java:66)

I require any combination of .java, .class, or .jar files that I can just drop into my project without requiring Maven or XML file/directory configuration of any kind. Just something simple that does what it advertises.

user1258361
  • 1,133
  • 2
  • 16
  • 25
  • Possibly related: http://stackoverflow.com/questions/3690552/spring-simplelogger-does-not-seem-to-be-location-aware-exception – beny23 Mar 29 '12 at 19:09
  • I'm writing a Java program to communicate with a Cassandra database – user1258361 Mar 29 '12 at 19:36
  • 2
    If you don't want to deal with maven, the hector project provides tar.gz downloads on the github site. It isn't a single jar but it is all the jars hector creates or depends on. https://github.com/rantav/hector/downloads – nickmbailey Mar 29 '12 at 21:37
  • 1
    "java.lang.UnsupportedOperationException: This code should have never made it into the jar " Love that error message. – Thilo Mar 30 '12 at 09:12

3 Answers3

3

As you're using Eclipse, why not use the built-in maven functionality? This would allow you to:

"...just drop into my Eclipse project and begin using out of the box, without having to install, configure, and debug additional 3rd-party software".

Place the following into your pom.xml:

      <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>1.6.4</version>
      </dependency>
      <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-log4j12</artifactId>
                <version>1.6.4</version>
      </dependency>
      <dependency>
                <groupId>me.prettyprint</groupId>
                <artifactId>hector-core</artifactId>
                <version>1.0-4</version>
      </dependency>

Your code should then work.

Strongly encourage you to look into Why maven? What are the benefits?

Finally, if you're unwilling to go the easy and fairly standard road, you can follow Nick's suggestion: https://github.com/rantav/hector/downloads and download the tar.gz that contains all of the jar's and add them to your classpath.

Community
  • 1
  • 1
sdolgy
  • 6,963
  • 3
  • 41
  • 61
  • it is better to keep the slf4j versions same,instead of combining different versions – fmucar Mar 30 '12 at 12:11
  • The tar.gz works so far. Thanks! If you haven't noticed, I have accepted your post as an answer and upvoted it. – user1258361 Apr 02 '12 at 14:31
  • EDIT: I'm getting a run-time exception : "java.lang.NoClassDefFoundError: org/apache/thrift/TBase" using the most recent version of the zipped JAR files. I'm re-opening the question. I have all of the JARs in the zip file included in my Eclipse Build Path. – user1258361 Apr 02 '12 at 17:17
  • like i said in the answer. use maven if you want to avoid the headaches of missing JAR files. – sdolgy Apr 02 '12 at 17:20
0

Netflix has created client for Cassandra and it seems to be better than Hector and it is also supported by big company. Just drop Maven dependency to your pom.xml and then you can try some examples form their wiki pages.

https://github.com/Netflix/astyanax

newbie
  • 24,286
  • 80
  • 201
  • 301
0

I figured it out.

HOW TO USE HECTOR WITHOUT MAVEN:

Download Hector from Github at https://github.com/rantav/hector/downloads

Now you need TBase and a bunch of other files. Get the jar file at http://www.java2s.com/Code/Jar/l/Downloadlibthrift060jar.htm

Unzip all of the downloads and put all of the JARs on your build path.

Start coding.

user1258361
  • 1,133
  • 2
  • 16
  • 25
  • 1
    obviously you didn't ... http://stackoverflow.com/questions/10001171/tired-of-debugging-issues-with-cassandra-apis-is-there-a-place-i-could-download – sdolgy Apr 04 '12 at 15:35