Announcement Announcement Module
Collapse
No announcement yet.
SimpleMessageContainer JbossMQ ClassCastException Problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    Whatever you are doing (it's no obvious from your code) you are creating somewhere a proxy without an interface.

    Joerg

    Comment


    • #3
      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

      Comment


      • #4
        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!

        Comment

        Working...
        X