Getting exception when @EnableRabbit

356 views
Skip to first unread message

Nilendu Kumar

unread,
May 30, 2018, 6:00:12 PM5/30/18
to rabbitmq-users
Hi, 

I am getting below error as soon as i am using @EnableRabbit. I am using Spring 4 with RabbitMQ ver 3.7.5

java.lang.NoSuchMethodError: org.springframework.util.Assert.state(ZLjava/util/function/Supplier;)V



Configuration File"

------------------


package com.onlineExam.config;

import org.springframework.amqp.core.AmqpAdmin;

import org.springframework.amqp.core.Queue;

import org.springframework.amqp.rabbit.annotation.EnableRabbit;

import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;

import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;

import org.springframework.amqp.rabbit.connection.ConnectionFactory;

import org.springframework.amqp.rabbit.core.RabbitAdmin;

import org.springframework.amqp.rabbit.core.RabbitTemplate;

import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;

import org.springframework.context.annotation.Bean;

import org.springframework.context.annotation.Configuration;


@Configuration

@EnableRabbit

public class RabbitMQConfig {

@Bean

public ConnectionFactory connectionFactory() {

CachingConnectionFactory connectionFactory = new CachingConnectionFactory("localhost");

connectionFactory.setUsername("guest");

connectionFactory.setPassword("guest");

connectionFactory.setPort(5672);


return connectionFactory;

}

@Bean

    public RabbitTemplate rabbitTemplate() {

        RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory());


        return rabbitTemplate;

    }


@Bean

public AmqpAdmin amqpAdmin() {

return new RabbitAdmin(connectionFactory());

}


@Bean

     public SimpleRabbitListenerContainerFactory myRabbitListenerContainerFactory() {

       SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();

       factory.setConnectionFactory(connectionFactory());

       factory.setMaxConcurrentConsumers(5);

       

       return factory;

     }

    @Bean

    public Queue hello() {

    System.out.println("Queue created");

        return new Queue("hello");

    }


    @Bean

    public Tut1Receiver receiver() {

    System.out.println("Receiver created");

        return new Tut1Receiver();

    }


    @Bean

    public Tut1Sender sender() {

    System.out.println("Sender created");

        return new Tut1Sender();

    }


}



Receiver File 

---------------


package com.onlineExam.config;


import org.springframework.amqp.rabbit.annotation.RabbitHandler;

import org.springframework.amqp.rabbit.annotation.RabbitListener;


@RabbitListener(containerFactory="myRabbitListenerContainerFactory", queues="hello")

public class Tut1Receiver {


@RabbitHandler

    public void process(String msg) {

        // process incoming message

    }

}

Michael Klishin

unread,
May 30, 2018, 7:18:00 PM5/30/18
to rabbitm...@googlegroups.com
You will get a response quicker if you post your Spring (including Spring AMQP) questions
to Stack Overflow and label them with spring-amqp.

java.lang.NoSuchMethodError strongly suggests a dependency or JDK version mismatch.
I doubt this is RabbitMQ-specific.

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
MK

Staff Software Engineer, Pivotal/RabbitMQ

Gary Russell

unread,
May 30, 2018, 8:05:33 PM5/30/18
to rabbitm...@googlegroups.com
>java.lang.NoSuchMethodError: org.springframework.util.Assert.state(ZLjava/util/function/Supplier;)V

It looks like you are using Spring AMQP 2.x; it requires Spring 5, not Spring Framework 4.

Upgrade Spring or downgrade Spring AMQP to 1.7.8 (which is compatible with Spring Framework 4.3).

To post to this group, send email to rabbitm...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--
MK

Staff Software Engineer, Pivotal/RabbitMQ

Nilendu Kumar

unread,
May 31, 2018, 2:16:28 AM5/31/18
to rabbitmq-users
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.

To post to this group, send email to rabbitm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
MK

Staff Software Engineer, Pivotal/RabbitMQ

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.

To post to this group, send email to rabbitm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



@Gary , It Worked after downgrading Spring AMQP to 1.7.8 , thank a lot 
Reply all
Reply to author
Forward
0 new messages