java.lang.IllegalStateException

If you like a tip written by other Samebug users, mark is as helpful! Marks help our algorithm provide you better solutions and also help other users.
tip

If you're using boot 1.4.x you need to modify the @springBootTest annotation to @SpringBootTest(classes = DataFlowServerConfiguration.class). 1.3.8 doesn't have this problem as well.

tip

Spring Boot 1.4 changed their annotation system a little. Try using the @SpringBootApplication annotation for better results.


rafaelrafael

You have a different solution? A short tip here would help you and many other users who saw this issue last week.

  • If we have following situation: interface: {code:title=ConsumerService.java |borderStyle=solid} public interface ConsumerService<TPayLoad> { void consume(TPayLoad message); } {code} and also following interface implementation: {code:title=TestingQueueConsumerServiceImpl.java |borderStyle=solid} @Component public class TestingQueueConsumerServiceImpl implements ConsumerService<DemoMessage> { private Log log = LogFactory.getLog(getClass()); @Transactional @RabbitListener(queues = "${rabbitmq.queue.demo}", id = "myuniquecustomid") public void consume(@Payload TestMessage message) { Assert.notNull(message); log.info(message.toString()); } } {code} on application start we gets following exception {noformat} 2016-03-24 09:26:48.971 INFO 58632 --- [ main] o.apache.catalina.core.StandardService : Stopping service Tomcat 2016-03-24 09:26:48.982 ERROR 58632 --- [ main] o.s.boot.SpringApplication : Application startup failed java.lang.IllegalStateException: Another endpoint is already registered with id 'myuniquecustomid' at org.springframework.util.Assert.state(Assert.java:392) ~[spring-core-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistry.registerListenerContainer(RabbitListenerEndpointRegistry.java:146) ~[spring-rabbit-1.5.4.RELEASE.jar:na] at org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistry.registerListenerContainer(RabbitListenerEndpointRegistry.java:122) ~[spring-rabbit-1.5.4.RELEASE.jar:na] at org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistrar.registerAllEndpoints(RabbitListenerEndpointRegistrar.java:134) ~[spring-rabbit-1.5.4.RELEASE.jar:na] at org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistrar.afterPropertiesSet(RabbitListenerEndpointRegistrar.java:128) ~[spring-rabbit-1.5.4.RELEASE.jar:na] at org.springframework.amqp.rabbit.annotation.RabbitListenerAnnotationBeanPostProcessor.afterSingletonsInstantiated(RabbitListenerAnnotationBeanPostProcessor.java:209) ~[spring-rabbit-1.5.4.RELEASE.jar:na] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:792) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1191) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1180) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE] {noformat} This is happening as @RabbitListener annotation creates two listener instances, one for interface method and one for implementing method. After implementation of `ConsumerService<DemoMessage>` is removed then everything is working as expected.
    via by Josip Medic,
  • If we have following situation: interface: {code:title=ConsumerService.java |borderStyle=solid} public interface ConsumerService<TPayLoad> { void consume(TPayLoad message); } {code} and also following interface implementation: {code:title=TestingQueueConsumerServiceImpl.java |borderStyle=solid} @Component public class TestingQueueConsumerServiceImpl implements ConsumerService<DemoMessage> { private Log log = LogFactory.getLog(getClass()); @Transactional @RabbitListener(queues = "${rabbitmq.queue.demo}", id = "myuniquecustomid") public void consume(@Payload TestMessage message) { Assert.notNull(message); log.info(message.toString()); } } {code} on application start we gets following exception {noformat} 2016-03-24 09:26:48.971 INFO 58632 --- [ main] o.apache.catalina.core.StandardService : Stopping service Tomcat 2016-03-24 09:26:48.982 ERROR 58632 --- [ main] o.s.boot.SpringApplication : Application startup failed java.lang.IllegalStateException: Another endpoint is already registered with id 'myuniquecustomid' at org.springframework.util.Assert.state(Assert.java:392) ~[spring-core-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistry.registerListenerContainer(RabbitListenerEndpointRegistry.java:146) ~[spring-rabbit-1.5.4.RELEASE.jar:na] at org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistry.registerListenerContainer(RabbitListenerEndpointRegistry.java:122) ~[spring-rabbit-1.5.4.RELEASE.jar:na] at org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistrar.registerAllEndpoints(RabbitListenerEndpointRegistrar.java:134) ~[spring-rabbit-1.5.4.RELEASE.jar:na] at org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistrar.afterPropertiesSet(RabbitListenerEndpointRegistrar.java:128) ~[spring-rabbit-1.5.4.RELEASE.jar:na] at org.springframework.amqp.rabbit.annotation.RabbitListenerAnnotationBeanPostProcessor.afterSingletonsInstantiated(RabbitListenerAnnotationBeanPostProcessor.java:209) ~[spring-rabbit-1.5.4.RELEASE.jar:na] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:792) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1191) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1180) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE] {noformat} This is happening as @RabbitListener annotation creates two listener instances, one for interface method and one for implementing method. After implementation of `ConsumerService<DemoMessage>` is removed then everything is working as expected.
    via by Josip Medic,
  • GitHub comment 11#155290898
    via GitHub by artembilan
    ,
    • java.lang.IllegalStateException: Another endpoint is already registered with id 'myuniquecustomid' at org.springframework.util.Assert.state(Assert.java:392)[spring-core-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistry.registerListenerContainer(RabbitListenerEndpointRegistry.java:146)[spring-rabbit-1.5.4.RELEASE.jar:na] at org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistry.registerListenerContainer(RabbitListenerEndpointRegistry.java:122)[spring-rabbit-1.5.4.RELEASE.jar:na] at org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistrar.registerAllEndpoints(RabbitListenerEndpointRegistrar.java:134)[spring-rabbit-1.5.4.RELEASE.jar:na] at org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistrar.afterPropertiesSet(RabbitListenerEndpointRegistrar.java:128)[spring-rabbit-1.5.4.RELEASE.jar:na] at org.springframework.amqp.rabbit.annotation.RabbitListenerAnnotationBeanPostProcessor.afterSingletonsInstantiated(RabbitListenerAnnotationBeanPostProcessor.java:209)[spring-rabbit-1.5.4.RELEASE.jar:na] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:792)[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)[spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766)[spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361)[spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)[spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1191)[spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1180)[spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]

    Users with the same issue

    tvrmsmithtvrmsmith
    23 times, last one,
    bernardpaulusbernardpaulus
    18 times, last one,
    DunmerDunmer
    1 times, last one,
    SteVio1989SteVio1989
    8 times, last one,
    jpveejpvee
    4 times, last one,
    62 more bugmates