jms 初始化报错 java.lang.reflect.MalformedParameterizedTypeException

系统:win7

环境:maven3.0.5

jre:JavaSE-1.6

运行环境:tomcat

涉及到的主要jar包:activemq-all-5.8.0.jar,activemq-pool-5.8.0.jar,commons-pool-1.6.jar

引入jms:applicationContext-jms.xml

<?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:p="http://www.springframework.org/schema/p"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd"
default-lazy-init="false" default-autowire="byName">


<!-- 消息队列工厂 added by xiluhua 2014-07-31->
<bean id="jmsFactory" class="org.apache.activemq.pool.PooledConnectionFactory">
<property name="connectionFactory">
<bean class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="tcp://10.1.15.22:61616" />
</bean>
</property>
</bean>
<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory" ref="jmsFactory" />
<property name="receiveTimeout" value="1000" />
<property name="messageConverter">
<bean
class="org.springframework.jms.support.converter.SimpleMessageConverter" />
</property>
<property name="deliveryMode" value="2" /> <!-- 发送模式 DeliveryMode.NON_PERSISTENT=1:非持久 ; DeliveryMode.PERSISTENT=2:持久 -->
<property name="sessionAcknowledgeMode" value="1" />
</bean>
</beans>

1,spring初始化jmsFactory报错 java.lang.reflect.MalformedParameterizedTypeException

刚开始未引入commons-pool-1.6.jar,而使用了项目现成的commons-pool-1.3.jar,结果由于1.3不支持泛型,产生以上错误。

2,注意使用maven插件版的tomcat依赖jar包不可以使用<scope>system</scope>,这种方式编译能通过,但在运行是容器加载不到commons-pool-1.6.jar,必须上传到本地repository或项目所在私服。否则会产生Caused by: java.lang.ClassNotFoundException: org.apache.commons.pool.KeyedPoolableObjectFactory

 感谢成家荣的专栏给予的帮助:http://blog.csdn.net/yunye114105/article/details/15340677。

posted @ 2014-08-01 15:00  xiluhua  阅读(875)  评论(0编辑  收藏  举报