赫克托与卡桑德拉联系

发布于 2024-10-19 11:38:16 字数 2489 浏览 1 评论 0原文

我正在尝试将 cassandra 与 Hector 连接:

public class Main {
    public static void main(String[] args) {
        StringSerializer stringSerializer = StringSerializer.get();
        Cluster cluster = HFactory.getOrCreateCluster("Test Cluster", "localhost:9160");
        Keyspace keyspace =  HFactory.createKeyspace("Keyspace1", cluster);
        Mutator<String> mutator = HFactory.createMutator(keyspace, stringSerializer);
        mutator.insert("jsmith", "Standard1", HFactory.createStringColumn("first", "John"));
    }

}

问题:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
    at org.slf4j.LoggerFactory.getSingleton(LoggerFactory.java:230)
    at org.slf4j.LoggerFactory.bind(LoggerFactory.java:121)
    at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:112)
    at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:275)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:248)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:261)
    at me.prettyprint.cassandra.service.AbstractCluster.<init>(AbstractCluster.java:43)
    at me.prettyprint.cassandra.service.AbstractCluster.<init>(AbstractCluster.java:57)
    at me.prettyprint.cassandra.service.ThriftCluster.<init>(ThriftCluster.java:17)
    at me.prettyprint.hector.api.factory.HFactory.createCluster(HFactory.java:112)
    at me.prettyprint.hector.api.factory.HFactory.getOrCreateCluster(HFactory.java:104)
    at me.prettyprint.hector.api.factory.HFactory.getOrCreateCluster(HFactory.java:96)
    at javaapplication1.Main.main(Main.java:25)
Caused by: java.lang.ClassNotFoundException: org.slf4j.impl.StaticLoggerBinder
    at java.net.URLClassLoader$1.run(URLClassLoader.java:276)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:265)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:264)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:325)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:270)
    ... 13 more
Java Result: 1

我该如何解决?

我对赫克托和卡桑德拉已经失去了最后的耐心,我尝试过联系但失败了。 我运行 twissjava 示例并且它可以工作,但是当我扩展主类来进行我自己的测试时,它无法运行。

im trying to connect cassandra with Hector:

public class Main {
    public static void main(String[] args) {
        StringSerializer stringSerializer = StringSerializer.get();
        Cluster cluster = HFactory.getOrCreateCluster("Test Cluster", "localhost:9160");
        Keyspace keyspace =  HFactory.createKeyspace("Keyspace1", cluster);
        Mutator<String> mutator = HFactory.createMutator(keyspace, stringSerializer);
        mutator.insert("jsmith", "Standard1", HFactory.createStringColumn("first", "John"));
    }

}

The problem:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
    at org.slf4j.LoggerFactory.getSingleton(LoggerFactory.java:230)
    at org.slf4j.LoggerFactory.bind(LoggerFactory.java:121)
    at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:112)
    at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:275)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:248)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:261)
    at me.prettyprint.cassandra.service.AbstractCluster.<init>(AbstractCluster.java:43)
    at me.prettyprint.cassandra.service.AbstractCluster.<init>(AbstractCluster.java:57)
    at me.prettyprint.cassandra.service.ThriftCluster.<init>(ThriftCluster.java:17)
    at me.prettyprint.hector.api.factory.HFactory.createCluster(HFactory.java:112)
    at me.prettyprint.hector.api.factory.HFactory.getOrCreateCluster(HFactory.java:104)
    at me.prettyprint.hector.api.factory.HFactory.getOrCreateCluster(HFactory.java:96)
    at javaapplication1.Main.main(Main.java:25)
Caused by: java.lang.ClassNotFoundException: org.slf4j.impl.StaticLoggerBinder
    at java.net.URLClassLoader$1.run(URLClassLoader.java:276)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:265)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:264)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:325)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:270)
    ... 13 more
Java Result: 1

How could i solve?

I'm down to my last patience with hector and cassandra, I have tried to connect and failed.
i run twissjava sample and it works, but when i extend the main class to make my own test it doesn't run.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

仙女山的月亮 2024-10-26 11:38:16

此问题”记录在 wiki 的 “SLF4J in Hector”页面< /a>

简短版本:您需要添加一个实现 SLF4J api 的库。

This problem" is documented on the wiki on the "SLF4J in Hector"-page

Short version: you need to add a library that implements the SLF4J api.

不疑不惑不回忆 2024-10-26 11:38:16

你必须将像 SLF4j、Log4j 这样的 Hector 依赖项添加到你的类路径中,然后你的问题就会解决..我有完全相同的问题给你,我的问题也解决了..对不起我的英语..:D

you have to add Hector dependencies like SLF4j,Log4j to your classpath,then your problem will solved..i have exactly same problem to you and my problem solved..sorry for my english..:D

百合的盛世恋 2024-10-26 11:38:16

您使用什么开发环境?

我在 netbeans 中也遇到了同样的问题。
以下是您需要的文件(但请注意您正在使用的版本)。

log4j下载: http://www. findjar.com/jar/log4j/log4j/1.2.11/log4j-1.2.11.jar.html
slf4j 下载:http://www.findjar.com/jar/de/huxhorn/lilith/de.huxhorn.lilith.slf4j/0.9.35/de.huxhorn.lilith.slf4j-0.9。 35.jar.html

ps 如果这些版本不起作用,请在 findjar 网站上搜索正确的版本,但我将这两个版本与 cassandra 1.0.7 和 hector 1.0.2 一起使用,它们对我有用。

What development environment are you using?

I had the same problem in netbeans.
Here are the files you need (but be carefull about the versions you are using).

log4j download: http://www.findjar.com/jar/log4j/log4j/1.2.11/log4j-1.2.11.jar.html
slf4j download: http://www.findjar.com/jar/de/huxhorn/lilith/de.huxhorn.lilith.slf4j/0.9.35/de.huxhorn.lilith.slf4j-0.9.35.jar.html

p.s. search the findjar website for the correct versions if these ones dont work, but i'm using these two with cassandra 1.0.7 and hector 1.0.2 and they worked for me.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文