Question

I'm getting this error when I try to publish a string in a channel:

java.lang.AbstractMethodError: org.cometd.client.BayeuxClient$BayeuxClientChannel.publish(Ljava/lang/Object;)V

this is the code that is trying to publish:

public class EnviadorMensagem implements Runnable {

private String nomeCanal;
private Mensagem mensagem;
private ClientSession cliente;
private boolean pausado = true;
private boolean cancelado = false;

@Override
public void run() {
    while (pausado) {
        pausar();
    }
    if (!cancelado) {
        converterEEnviar();
    }
}

private void pausar() {
    synchronized (this) {
        try {
            this.wait();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}

private void converterEEnviar() {
    ConversorMensagem conversor = new ConversorMensagem();
    ClientSessionChannel canal = cliente.getChannel(nomeCanal);
    canal.publish(conversor.converter(mensagem)); //<- the error happens here!!
}

public void ativar() {
    synchronized (this) {
        pausado = false;
        this.notifyAll();
    }
}

public void cancelar() {
    synchronized (this) {
        cancelado = true;
    }
    ativar();
}

public void setNomeCanal(String nomeCanal) {
    this.nomeCanal = nomeCanal;
}

public void setMensagem(Mensagem mensagem) {
    this.mensagem = mensagem;
}

public void setCliente(ClientSession cliente) {
    this.cliente = cliente;
}
}

As you can see, this class is running in a separate thread. this is part of my pom.xml:

<dependencies>
    <dependency>
        <groupId>org.cometd.java</groupId>
        <artifactId>cometd-java-client</artifactId>
        <version>2.5.1</version>
    </dependency>
    <dependency>
        <groupId>org.cometd.java</groupId>
        <artifactId>bayeux-api</artifactId>
        <version>2.5.1</version>
    </dependency>
    <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-client</artifactId>
        <version>8.1.7.v20120910</version>
    </dependency>
</dependencies>

Someone knows how to solve it??

Was it helpful?

Solution

You get AbstractMethodError when you compiled your code against a version of a library, but at runtime you are using another, that does not have that method, or has it with a different signature.

Double check your classpath and the CometD library versions you're using.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top