Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-9930

When SimpleMessageListenerContainer could not connect, it throws a NullPointerException in shutdown()

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: 3.0.7
    • Fix Version/s: 3.1.3, 3.2 RC1
    • Component/s: JMS
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      When I start a simpleMessageListenerContainer while the ActiveMQ server is down, I get:

      to perform GET on: http://localhost:22012 as response was: Connection to http://localhost:22012 refused
              at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:35)
              at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:295)
              at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:239)
              at org.apache.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:185)
              at org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:184)
              at org.springframework.jms.listener.AbstractJmsListeningContainer.createSharedConnection(AbstractJmsListeningContainer.java:403)
              at org.springframework.jms.listener.AbstractJmsListeningContainer.establishSharedConnection(AbstractJmsListeningContainer.java:371)
              at org.springframework.jms.listener.SimpleMessageListenerContainer.doInitialize(SimpleMessageListenerContainer.java:187)
       
              at org.springframework.jms.listener.AbstractJmsListeningContainer.initialize(AbstractJmsListeningContainer.java:193)
              ... 10 more

      I can catch this exception, and the container will keep retrying, which is a good thing.

      If I want to shut it down, I do

                          try
                          {
                              if (jmsContainer.isRunning())
                              {
                                  jmsContainer.stop();
                              }
                              jmsContainer.destroy();
                              jmsContainer = null;
                          }
                          catch (JmsException e)
                          {
                              log.warn("Exception stopping listener: ", e);
                          }

      But here I get a NullPointerException from the destroy():

      Caused by: java.lang.NullPointerException
              at org.springframework.jms.listener.SimpleMessageListenerContainer.doShutdown(SimpleMessageListenerContainer.java:325)
              at org.springframework.jms.listener.AbstractJmsListeningContainer.shutdown(AbstractJmsListeningContainer.java:231)
              at org.springframework.jms.listener.AbstractJmsListeningContainer.destroy(AbstractJmsListeningContainer.java:172)

      Apparently, this.consumers and this.sessions are null, while you try to iterate over them.

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            juergen.hoeller Juergen Hoeller
            Reporter:
            greyfairer Geert Pante
            Last updater:
            Chris Beams
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Days since last comment:
              5 years, 4 weeks, 3 days ago