Results 1 to 4 of 4

Thread: SimpleMessageContainer JbossMQ ClassCastException Problem

  1. #1
    Join Date
    May 2007
    Posts
    4

    Default SimpleMessageContainer JbossMQ ClassCastException Problem

    Hi

    I've recently tried adding JMS to the Spring App I'm developing and have run into a problem. I'm using JBoss4.0.5 with JBossMQ as the JMS provider but my SimpleMessageListenerContainer bean fails with a ClassCast Exception:

    Code:
    12:11:28,455 ERROR [[/app]] Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'listenerContainer' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.ClassCastException: $Proxy120
    Caused by: 
    java.lang.ClassCastException: $Proxy120
            at org.jboss.mq.SpyQueueReceiver.<init>(SpyQueueReceiver.java:49)
            at org.jboss.mq.SpySession.createReceiver(SpySession.java:657)
            at org.jboss.mq.SpySession.createConsumer(SpySession.java:619)
            at org.jboss.mq.SpySession.createConsumer(SpySession.java:610)
            at org.jboss.resource.adapter.jms.JmsSession.createConsumer(JmsSession.java:473)
            at org.springframework.jms.listener.SimpleMessageListenerContainer.createConsumer(SimpleMessageListenerContainer.java:255)
            at org.springframework.jms.listener.SimpleMessageListenerContainer.createListenerConsumer(SimpleMessageListenerContainer.java:190)
            at org.springframework.jms.listener.SimpleMessageListenerContainer.doInitialize(SimpleMessageListenerContainer.java:171)
    Here are the relevant bean definitions:

    Code:
    <bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
        	<property name="jndiName" value="java:/ConnectionFactory"/>
    </bean>
    	
    <bean id="searchQueue" class="org.springframework.jndi.JndiObjectFactoryBean">
        	<property name="jndiName" value="queue/SearchQueue"/>
    </bean>
    	
    <bean id="searchListener" class="test.jms.SearchListener" />
    
    <bean id="listenerContainer"
     class="org.springframework.jms.listener.SimpleMessageListenerContainer">
      		<property name="concurrentConsumers" value="5"/>
      		<property name="connectionFactory" ref="connectionFactory" />
      		<property name="destination" ref="searchQueue" />
      		<property name="messageListener" ref="searchListener" />
    </bean>
    Could anyone give me some insight into what I'm doing wrong?

    Cheers,
    Ben

  2. #2
    Join Date
    Nov 2005
    Location
    Reutlingen, Germany
    Posts
    2,098

    Default

    Whatever you are doing (it's no obvious from your code) you are creating somewhere a proxy without an interface.

    Joerg
    This post can contain insufficient information.

  3. #3
    Join Date
    May 2007
    Posts
    4

    Default

    From your reply and my own Googling I'm pretty sure this is something to do with my problems:

    http://jira.jboss.com/jira/browse/JBAS-3035

    so trying to figure out how to work around it. Currently thinking of just using normal POJOs that do the JNDI lookups themselves. Very unSpring like but hopefully will be less work than switching to another JMS provider.

    Cheers,
    Ben

  4. #4
    Join Date
    May 2007
    Posts
    4

    Default

    Got this working doing the JNDI lookups inside my own POJO's instead of using JNDIObjectFactoryBean.

    Only one small gotcha, if you create the ListenerContainer programatically be sure to call the afterPropertiesSet() method on it once you've set the connectionFactory, destination etc. otherwise nothing much will happen!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •