Hello,
I am trying to get acquainted to spring jms functionalities as i need to use it as a part of several projects we have in the pipeline and i am kinda running short of time here as usual with developers.
I scooped up a couple of code snippets from the net and i have tweaked the spring config file as i am using ActiveMQ as my local MQ manager.
Here is my spring config file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//Spring//DTD Bean//EN"
"
http://www.springframework.org/dtd/spring-beans.dtd">
<!-- Application Context -->
<beans>
<!-- JNDI Environment Template -->
<bean id="jndiTemplate" class="org.springframework
.jndi.Jndi
Template">
<property name="environment">
<props>
<prop key="java.naming.factory.i
nitial">or
g.apache.a
ctiv emq.jndi.ActiveMQInitialCo
ntextFacto
ry</prop>
<prop key="java.naming.provider.
url">tcp:/
/localhost
:61616</pr
op>
</props>
</property>
</bean>
<!-- JMS Queue Connection Factory -->
<bean id="internalJmsQueueConnec
tionFactor
y"
class="org.springframework
.jndi.Jndi
ObjectFact
oryB ean">
<property name="jndiTemplate">
<ref bean="jndiTemplate"/>
</property>
<property name="jndiName">
<value>MyQueue</value>
</property>
</bean>
<!-- Spring Wrapped JMS Queue Connection Factory -->
<bean id="jmsQueueConnectionFact
ory"
class="org.springframework
.jms.conne
ction.Sing
leCo nnectionFactory102">
<property name="targetConnectionFact
ory">
<ref bean="internalJmsQueueConn
ectionFact
ory"/>
</property>
<property name="pubSubDomain">
<value>false</value>
</property>
</bean>
<!-- JMS Destination Resolver -->
<bean id="jmsDestinationResolver
"
class="org.springframework
.jms.suppo
rt.destina
tion .JndiDestinationResolver">
<property name="jndiTemplate">
<ref bean="jndiTemplate"/>
</property>
<property name="cache">
<value>true</value>
</property>
</bean>
<!-- JMS Queue Template -->
<bean id="jmsQueueTemplate" class="org.springframework
.jms.core.
JmsTemplat
e102 ">
<property name="connectionFactory">
<!-- <ref bean="jmsQueueConnectionFa
ctory"/>--
>
<ref bean="internalJmsQueueConn
ectionFact
ory"/>
</property>
<property name="destinationResolver"
>
<ref bean="jmsDestinationResolv
er"/>
</property>
<property name="pubSubDomain">
<value>false</value>
</property>
<property name="receiveTimeout">
<value>20000</value>
</property>
</bean>
<bean id="jmsSender" class="springexample.clien
t.JMSSende
r">
<property name="jmsTemplate102">
<ref bean="jmsQueueTemplate"/>
</property>
</bean>
<bean id="jmsReceiver" class="springexample.clien
t.JMSRecei
ver">
<property name="jmsTemplate102">
<ref bean="jmsQueueTemplate"/>
</property>
</bean>
</beans>
and when i run my associated programs, i get a type mismatch for "connectionFactory" under "jmsQueueTemplate". The exact exception that i see is org.springframework.beans.
TypeMismat
chExceptio
n: Failed to convert property value of type [org.apache.activemq.comma
nd.ActiveM
QQueue] to required type [javax.jms.ConnectionFacto
ry] for property 'targetConnectionFactory';
nested exception is java.lang.IllegalArgumentE
xception:
How should i go about casting the objects to the appropriate type?
Let me know if you guys need any more information regarding the code and/or error.
Any help is truly appreciated
Thanks whizkid007