首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ClassNotFoundException与JGroups

ClassNotFoundException与JGroups
EN

Stack Overflow用户
提问于 2013-12-10 03:10:16
回答 1查看 1.6K关注 0票数 1

我对JGroups有一个问题,在构建我的项目之后,运行它会产生以下错误:

Caused by: java.lang.ClassNotFoundException: org.jgroups.ReceiverAdapter

我的课看起来像这样-

代码语言:javascript
复制
import org.jgroups.ReceiverAdapter;
import org.jgroups.Channel;
import org.jgroups.JChannel;

public class MyClass extends ReceiverAdapter implements MyInterface {

    Channel channel;
    String state = "state";

    public MyClass() {
        super();
        start();
    }

    public void start() {
        try {
            channel = new JChannel();
            channel.setReceiver(this);
            channel.connect("ServerCluster");
            channel.getState(null, 0);
            System.out.println("Connected to cluster");
        } catch (Exception e) {
            System.out.println("Failed to connect to cluster");
        }
    }

    public void getState(OutputStream output) throws Exception {
        System.out.println("get response");
    }

    public void setState(InputStream input) throws Exception {
        System.out.println("set test");
    }
}

从IntelliJ运行项目不会产生错误,但也不会从getState()setState()生成所需的打印。我尝试在Eclipse中创建一个全新的项目,但同样的情况也发生在那里。连接一直运行良好,状态是我的项目的一个新的补充。

从命令行运行java MyClass会触发在此问题开始时看到的错误。JGroups jar似乎被正确地添加到类路径中,因为org.jgroups.Channelorg.jgroups.Channel (以及其他)正在被找到。

有一个由SimpleChat开发人员提供的JGroup程序,但是当我为此创建一个新的项目时,我遇到了同样的问题。

编辑

因此,在从CLI运行时,我必须显式地设置类路径。但是,在运行代码时,getState()setState()方法似乎从未被调用过,因为没有print语句。SimpleChat不像它想要的那样打印received state...

有人有解决办法吗?

最好的。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-12-10 13:00:43

因此,我在JChannel上使用RpcDispatcher,似乎不能在同一个通道上使用dispatcher以及getState()setState()方法。简单的解决方案:创建第二个通道。看来我对JGroups的基础知识很缺乏!

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20485290

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档