You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by qin ding <qi...@yahoo.com> on 2010/08/03 18:14:35 UTC
Help with Activemq Spring support
ActiveMQ 5.3.2
Spring 2.0
I have a simple producer:
public class AdminProducer {
private static final Log log = LogFactory.getLog(AdminProducer.class);
private JmsTemplate jmsTemplate;
private Destination destination;
public void publish(final AdminInfo adminInfo) throws JMSException{
log.debug("in publish..."
jmsTemplate.send(destination, new MessageCreator() {
public Message createMessage(Session session) throws JMSException {
TextMessage message =
session.createTextMessage(adminInfo.toXml());
return message;
}
});
}
public JmsTemplate getJmsTemplate() {
return jmsTemplate;
}
public void setJmsTemplate(JmsTemplate jmsTemplate) {
this.jmsTemplate = jmsTemplate;
}
public Destination getDestination() {
return destination;
}
public void setDestination(Destination destination) {
this.destination = destination;
}
}
applicationContext.xml:
<!-- admin info producer -->
<bean id="adminProducer" class="com.mgt.lottery.poker.server.AdminProducer">
<property name="jmsTemplate" ref="jmsTemplate" />
<property name="destination" ref="adminTopic" />
</bean>
<!-- JMS ConnectionFactory to use -->
<bean id="jmsFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="tcp://localhost:61616/>
</bean>
<!-- Spring JMS Template -->
<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory">
<bean
class="org.springframework.jms.connection.SingleConnectionFactory">
<property name="targetConnectionFactory" ref="jmsFactory" />
</bean>
</property>
</bean>
<!-- admin destination topic -->
<bean id="adminTopic" class="org.apache.activemq.command.ActiveMQTopic"
autowire="constructor">
<constructor-arg value="mgt.lottery.poker.admin.topic" />
</bean>
I got the error:
Caused by: org.springframework.beans.TypeMismatchException: Failed to convert
property value of type [$Proxy5 implementing
org.springframework.jms.core.JmsOpera
tions,org.springframework.beans.factory.InitializingBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised]
to required type [org.sp
ringframework.jms.core.JmsTemplate] for property 'jmsTemplate'; nested
exception is java.lang.IllegalArgumentException: Cannot convert value of type
[$Proxy5 im
plementing
org.springframework.jms.core.JmsOperations,org.springframework.beans.factory.InitializingBean,org.springframework.aop.SpringProxy,org.springframework
.aop.framework.Advised] to required type
[org.springframework.jms.core.JmsTemplate] for property 'jmsTemplate': no
matching editors or conversion strategy found
at
org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:391)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1289)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1250)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
... 27 more
Caused by: java.lang.IllegalArgumentException: Cannot convert value of type
[$Proxy5 implementing
org.springframework.jms.core.JmsOperations,org.springframework
.beans.factory.InitializingBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised]
to required type [org.springframework.jms.core.Jm
sTemplate] for property 'jmsTemplate': no matching editors or conversion
strategy found
What should I do to fix this? Please help. Thanks.
QD