Hello,
I am sorry if i have started a thread the format of which could probably exist. Moderators please move this thread to the appropriate area if required.
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.JndiTemplate">
<property name="environment">
<props>
<prop key="java.naming.factory.initial">org.apache.activ emq.jndi.ActiveMQInitialContextFactory</prop>
<prop key="java.naming.provider.url">tcp://localhost:61616</prop>
</props>
</property>
</bean>
<!-- JMS Queue Connection Factory -->
<bean id="internalJmsQueueConnectionFactory"
class="org.springframework.jndi.JndiObjectFactoryB ean">
<property name="jndiTemplate">
<ref bean="jndiTemplate"/>
</property>
<property name="jndiName">
<value>MyQueue</value>
</property>
</bean>
<!-- Spring Wrapped JMS Queue Connection Factory -->
<bean id="jmsQueueConnectionFactory"
class="org.springframework.jms.connection.SingleCo nnectionFactory102">
<property name="targetConnectionFactory">
<ref bean="internalJmsQueueConnectionFactory"/>
</property>
<property name="pubSubDomain">
<value>false</value>
</property>
</bean>
<!-- JMS Destination Resolver -->
<bean id="jmsDestinationResolver"
class="org.springframework.jms.support.destination .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.JmsTemplate102 ">
<property name="connectionFactory">
<!-- <ref bean="jmsQueueConnectionFactory"/>-->
<ref bean="internalJmsQueueConnectionFactory"/>
</property>
<property name="destinationResolver">
<ref bean="jmsDestinationResolver"/>
</property>
<property name="pubSubDomain">
<value>false</value>
</property>
<property name="receiveTimeout">
<value>20000</value>
</property>
</bean>
<bean id="jmsSender" class="springexample.client.JMSSender">
<property name="jmsTemplate102">
<ref bean="jmsQueueTemplate"/>
</property>
</bean>
<bean id="jmsReceiver" class="springexample.client.JMSReceiver">
<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.TypeMismatchException: Failed to convert property value of type [org.apache.activemq.command.ActiveMQQueue] to required type [javax.jms.ConnectionFactory] for property 'targetConnectionFactory'; nested exception is java.lang.IllegalArgumentException:
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 Whiz


Reply With Quote
)
, thanks iwein