用spring2+websphere as提供的jms服务
JmsTemplate注入的connectionfactory和destination都报错,应该是强转的时候类型不匹配的错误,百思不得其解
这是spring配置文件
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util" xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.0.xsd">
<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
<property name="environment">
<props>
<prop key="java.naming.factory.initial">
com.ibm.websphere.naming.WsnInitialContextFactory
</prop>
<prop key="java.naming.provider.url">
iiop://192.168.3.253:2809
</prop>
<prop key="java.naming.factory.url.pkgs">
com.ibm.ws.naming
</prop>
</props>
</property>
</bean>
<bean id="jmsQueueConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate">
<ref bean="jndiTemplate"/>
</property>
<property name="jndiName">
<value>InfopushConnectionFactory</value>
</property>
</bean>
<bean id="sendDestination"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate">
<ref bean="jndiTemplate"/>
</property>
<property name="jndiName">
<value>InfopushQueue</value>
</property>
</bean>
<bean id="receiveDestination" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate">
<ref bean="jndiTemplate"/>
</property>
<property name="jndiName">
<value>InfopushQueue</value>
</property>
</bean>
<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory">
<ref bean="jmsQueueConnectionFactory"/>
</property>
<property name="defaultDestination">
<ref bean="sendDestination"/>
</property>
<property name="receiveTimeout">
<value>30000</value>
</property>
</bean>
<bean id="jmsSender" class="JMSSender">
<constructor-arg ref="jmsTemplate"/>
</bean>
<bean id="jmsReceiver" class="JMSReceiver">
</bean>
<bean id="listenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory" ref="jmsQueueConnectionFactory"/>
<property name="destination" ref="receiveDestination"/>
<property name="messageListener" ref="jmsReceiver"/>
</bean>
</beans>
报的关键错误如下
2012-6-1 16:07:43 org.springframework.beans.factory.support.DefaultSingletonBean
Registry destroySingletons
INFO: Destroying singletons in org.springframework.beans.factory.support.Default
ListableBeanFactory@37c537c5: defining beans [jndiTemplate,jmsQueueConnectionFac
tory,sendDestination,receiveDestination,jmsTemplate,jmsSender,jmsReceiver,listen
erContainer]; root of factory hierarchy
Exception in thread "P=62338:O=0:CT" org.springframework.beans.factory.BeanCreat
ionException: Error creating bean with name 'jmsTemplate' defined in class path
resource [spring-config.xml]: Error setting property values; nested exception is
org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessEx
ceptions (2) are:
PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Fail
ed to convert property value of type [javax.naming.Reference] to required type [
javax.jms.ConnectionFactory] for property 'connectionFactory'; nested exception
is java.lang.IllegalArgumentException: Cannot convert value of type [javax.namin
g.Reference] to required type [javax.jms.ConnectionFactory] for property 'connec
tionFactory': no matching editors or conversion strategy found
PropertyAccessException 2: org.springframework.beans.TypeMismatchException: Fail
ed to convert property value of type [javax.naming.Reference] to required type [
javax.jms.Destination] for property 'defaultDestination'; nested exception is ja
va.lang.IllegalArgumentException: Cannot convert value of type [javax.naming.Ref
erence] to required type [javax.jms.Destination] for property 'defaultDestinatio
n': no matching editors or conversion strategy found
Caused by: org.springframework.beans.PropertyBatchUpdateException; nested Proper
tyAccessException details (2) are:
PropertyAccessException 1:
org.springframework.beans.TypeMismatchException: Failed to convert property valu
e of type [javax.naming.Reference] to required type [javax.jms.ConnectionFactory
] for property 'connectionFactory'; nested exception is java.lang.IllegalArgumen
tException: Cannot convert value of type [javax.naming.Reference] to required ty
pe [javax.jms.ConnectionFactory] for property 'connectionFactory': no matching e
ditors or conversion strategy found
Caused by: java.lang.IllegalArgumentException: Cannot convert value of type [jav
ax.naming.Reference] to required type [javax.jms.ConnectionFactory] for property
'connectionFactory': no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(Ty
peConverterDelegate.java:231)
Cannot convert value of type [javax.naming.Reference] to required type javax.jms.ConnectionFactory] for property 'connectionFactory': no matching editors or conversion strategy found
这错误怎么提示要把javax.naming.Reference转成ConnectionFactory
相关推荐
标题 "Spring JMSTemplate 与 JMS 原生API比较" 涉及到的是Java消息服务(Java Message Service,JMS)在Spring框架中的使用,特别是Spring提供的JMSTemplate与JMS原生API之间的差异。JMS是一种标准接口,用于在...
JmsTemplate jmsTemplate = (JmsTemplate) context.getBean("jmsQueueTemplate"); Destination destination = (Destination) context.getBean("defaultQueueDestination"); JmsUtil.sendMessage(jmsTemplate, de
JMS与Spring之一(用JmsTemplate同步收发消息) JMS(Java Message Service)是一种Java API,用于在两个应用程序之间异步地发送消息。Spring框架提供了对JMS的支持,允许开发者使用JMS template或message listener...
JmsTemplate是Spring框架为简化JMS操作提供的一个工具类,它封装了发送和接收消息的复杂性,使得开发者能够更方便地使用JMS。使用JmsTemplate,我们可以直接调用其send()方法向队列发送消息。以下是一个简单的示例:...
【Java】分享基于Spring的JmsTemplate和消息中间件ActiveMQ实现消息发送接受实践工程源码
【Java】分享基于Spring的JmsTemplate和消息中间件ActiveMQ实现消息发送接受实践工程源码_pgj
JMS(使用消息中介:ActiveMQ) ...JmsTemplate是Spring消除冗长和重复JMS代码的解决方案。JmsTemplate可以创建连接,获取会话,以及发送和接收消息。http://blog.csdn.net/facepp/archive/2008/11/26/3374151.aspx
IBM WebSphere MQ是一个广泛使用的消息中间件产品,Spring JMS可以很容易地与之集成,为开发者提供一个健壮且灵活的消息传递平台。 - **安装与配置**:首先需要确保IBM WebSphere MQ环境已正确安装并配置好。接着,...
Spring框架是Java开发中不可或缺的一部分,它以其强大的依赖注入(DI)和面向切面编程(AOP)功能闻名。在Spring 4.3版本中,我们看到了许多改进和优化,这些变化对理解Spring的工作原理至关重要。现在,我们将深入...
在IT行业中,Spring框架是Java应用开发中的一个关键组件,它提供了一个全面的编程和配置模型,用于构建灵活、可维护的应用程序。而ActiveMQ则是Apache软件基金会的一个开源项目,它是Java消息服务(JMS)的实现,...
在IT行业中,Spring框架是Java应用开发中的一个关键组件,它提供了一个全面的编程和配置模型,使得构建复杂的、有弹性的和协作的应用程序变得更加容易。而ActiveMQ则是Apache出品的一款开源的消息中间件,它是Java...
`JmsTemplate`是Spring提供的一个工具类,它可以方便地发送不同类型的JMS消息。 - 消费者代码(Consumer)通常包含一个实现了`MessageListener`接口的类,这个类会被Spring容器自动初始化,并通过`...
Spring的`JmsTemplate`是这个抽象层的核心,它简化了发送和接收消息的操作。 2. **Message Listener Container**:Spring提供了两种类型的消息监听容器——`DefaultMessageListenerContainer`和`...
SpringActiveMQ入门示例是关于如何在Java环境中利用Spring框架与Apache ActiveMQ集成的一个实践教程。这个示例主要适用于开发者想要了解如何在Spring应用中使用消息队列进行异步通信和解耦。在这个项目中,开发环境...
在IT行业中,Spring框架是Java应用开发中的一个关键组件,特别是在企业级应用中,它提供了丰富的功能,包括依赖注入、AOP(面向切面编程)以及对消息中间件的支持。Oracle Advanced Queuing(AQ)是Oracle数据库内置...
MessageListenerContainer是Spring JMS用于异步处理消息的组件,它可以监听一个或多个队列或主题,并在接收到消息时调用预先注册的MessageListener。这使得应用程序可以专注于业务逻辑,而无需关心消息的接收和处理...
在Spring的XML配置文件中,我们需要引入ActiveMQ的相关库,并定义一个`JmsTemplate`实例,这是Spring用于发送和接收消息的主要工具。例如: ```xml <bean id="jmsTemplate" class="org.springframework.jms....
2. **配置JmsTemplate**:接下来,我们需要创建一个`JmsTemplate`实例,它是发送和接收消息的主要工具。配置如下: ```java @Bean public JmsTemplate jmsTemplate(ConnectionFactory connectionFactory) { ...
在Java世界中,ActiveMQ和Spring的整合是企业级应用中常见的消息中间件解决方案,用于实现JMS(Java Message Service)消息传递。本教程将深入探讨如何将这两个强大的工具结合在一起,以创建一个简单的发送JMS消息的...
而Spring框架是Java开发中广泛使用的轻量级框架,它提供了一个全面的编程和配置模型,使得开发企业级应用变得更加简单。整合JMS与Spring可以帮助我们构建更高效、可扩展的消息驱动系统。 在Spring框架中,我们可以...