Announcement Announcement Module
Collapse
No announcement yet.
NoSuchMethodException error occuring when enabling listener to conumer messages Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • NoSuchMethodException error occuring when enabling listener to conumer messages

    I am writing an application to enable/disable listeners. The application is being deployed on tomat. Upon deploying the application I am seeing the error below occur.


    [SimpleAsyncTaskExecutor-1] WARN 16:47:00,337 AbstractMessageListenerContainer.invokeErrorHandle r(178) - Execution of Rabbit message listener failed, and no ErrorHandler has been set.
    org.springframework.amqp.rabbit.listener.adapter.L istenerExecutionFailedException: Failed to invoke target method 'handleMessage' with argument type = [class java.lang.String], value = [{*********Testing Messsage sent from CBS ******}]
    at org.springframework.amqp.rabbit.listener.adapter.M essageListenerAdapter.invokeListenerMethod(Message ListenerAdapter.java:462)
    at org.springframework.amqp.rabbit.listener.adapter.M essageListenerAdapter.onMessage(MessageListenerAda pter.java:346)
    at org.springframework.amqp.rabbit.listener.AbstractM essageListenerContainer.doInvokeListener(AbstractM essageListenerContainer.java:288)
    at org.springframework.amqp.rabbit.listener.AbstractM essageListenerContainer.invokeListener(AbstractMes sageListenerContainer.java:250)
    at org.springframework.amqp.rabbit.listener.AbstractM essageListenerContainer.doExecuteListener(Abstract MessageListenerContainer.java:229)
    at org.springframework.amqp.rabbit.listener.AbstractM essageListenerContainer.executeListener(AbstractMe ssageListenerContainer.java:198)
    at org.springframework.amqp.rabbit.listener.SimpleMes sageListenerContainer.processMessage(SimpleMessage ListenerContainer.java:229)
    at org.springframework.amqp.rabbit.listener.SimpleMes sageListenerContainer$AsyncMessageProcessingConsum er.run(SimpleMessageListenerContainer.java:288)
    at java.lang.Thread.run(Thread.java:619)
    Caused by: java.lang.NoSuchMethodException: java.lang.String.handleMessage(java.lang.String)
    at java.lang.Class.getMethod(Class.java:1605)
    at org.springframework.util.MethodInvoker.prepare(Met hodInvoker.java:178)
    at org.springframework.amqp.rabbit.listener.adapter.M essageListenerAdapter.invokeListenerMethod(Message ListenerAdapter.java:442)
    ... 8 more
    [http-8080-exec-2] DEBUG 16:47:00,337 AppController.handleRequestInternal(25) - *******AppController.handleRequestInternal() -- ENABLED LISTENER
    [http-8080-exec-2] DEBUG 16:47:00,337 AppController.handleRequestInternal(30) - *******AppController.handleRequestInternal() -- Enabling listener
    [http-8080-exec-2] DEBUG 16:47:00,337 AppController.handleRequestInternal(35) - *******AppController.handleRequestInternal() -- returning Model
    [http-8080-exec-2] DEBUG 16:47:00,337 AbstractAutowireCapableBeanFactory.invokeInitMetho ds(1461) - Invoking afterPropertiesSet() on bean with name 'ListenerManagement'


    Below is my configuration for the listener.

    <bean id="connectionFactory" class="org.springframework.amqp.rabbit.connection. SingleConnectionFactory">
    <constructor-arg value="localhost"/>
    <property name="username" value="guest"/>
    <property name="password" value="guest"/>
    </bean>

    <bean id="messageListenerContainer" class="org.springframework.amqp.rabbit.listener.Si mpleMessageListenerContainer">
    <property name="connectionFactory" ref="connectionFactory" />
    <property name="queueName" value="cbs.push.queue"/>
    <property name="concurrentConsumers" value="1" />
    <property name="messageListener" ref="messageListenerAdapter" />

    </bean>

    <bean id="messageListenerAdapter" class="org.springframework.amqp.rabbit.listener.ad apter.MessageListenerAdapter">
    <property name="delegate" value="com.catmktg.digitalgateway.consumer.asynch. MessageHandler" />

    </bean>

    Here is my implementation for the message handler.



    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    import org.springframework.amqp.core.Message;

    public class MessageHandler {

    public void handleMessage(String text) {

    try {
    log.debug("************* Received CBS Msg. [" + text+ "]************************");

    } catch (Exception e) {
    log.debug("************* Error - handleMessage(String text)");
    e.printStackTrace();
    }

    }
    }

  • #2
    There's no bean definition for your handler, so Spring thinks it's a String:

    Code:
    value="com.catmktg.digitalgateway.consumer.asynch.MessageHandler"
    should be a ref= to another bean definition, or a nested inner <bean/> element.

    Comment


    • #3
      I feel like an idiot for missing that. Thank you sooooooooo much for responding.

      I would send you a box of choclates if i could

      Comment

      Working...
      X