在Tomcat部署war文件时出现java.lang.reflect.MalformedParameterizedTypeException异常

4

在使用Java 1.7时,通过Tomcat版本7.0.4部署时出现以下异常。尽管似乎与JDK 1.6正常工作。

2013-09-26 13:03:58,154 ERROR [org.springframework.web.context.ContextLoader] -
Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean wit
h name 'cxf' defined in class path resource [META-INF/cxf/cxf.xml]: Initializati
on of bean failed; nested exception is java.lang.reflect.MalformedParameterizedT
ypeException
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:480)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory$1.run(AbstractAutowireCapableBeanFactory.java:409)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:380)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
ject(AbstractBeanFactory.java:264)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
y.getSingleton(DefaultSingletonBeanRegistry.java:222)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
an(AbstractBeanFactory.java:261)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:185)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:164)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.
getBeansOfType(DefaultListableBeanFactory.java:308)
        at org.springframework.context.support.AbstractApplicationContext.getBea
nsOfType(AbstractApplicationContext.java:947)
        at org.springframework.context.support.AbstractApplicationContext.regist
erListeners(AbstractApplicationContext.java:701)
        at org.springframework.context.support.AbstractApplicationContext.refres
h(AbstractApplicationContext.java:377)

我发现问题与Spring JAR包的版本冲突有关。以下是我使用的Spring JAR包。

spring-2.5.5 - tried with 2.5.6 also
spring-aop-2.5.6
spring-beans-2.5.6
spring-context-2.5.6
spring-core-2.5.6
spring-jdbc-3.1.1.RELEASE - tried with 2.5.6 also
spring-orm-3.1.1.RELEASE - tried with 2.5.6 also
spring-transaction-3.1.1.RELEASE - tried with 2.5.6 also
spring-tx-3.1.1.RELEASE - tried with 2.5.6 also

Following are the cxf jars used.

cxf-api-2.6.0
cxf-bundle-jaxrs-2.6.0
cxf-rt-bindings-soap-2.6.0
cxf-rt-bindings-xml-2.6.0
cxf-rt-core-2.6.0
cxf-rt-databinding-jaxb-2.6.0
cxf-rt-frontend-jaxws-2.6.0
cxf-rt-frontend-simple-2.6.0
cxf-rt-transports-http-2.6.0
cxf-rt-ws-addr-2.6.0
cxf-rt-ws-policy-2.6.0

曾尝试将spring-aop-2.5.6,spring-beans-2.5.6,spring-context-2.5.6和spring-core-2.5.6替换为3.1.1版本,但是没有起到作用。

已经尝试删除元数据并检出新项目、进行干净的构建等操作,但似乎都没有用。请问有人可以帮我解决这个问题吗?我已经被困扰了两天。


您能否将配置文件(cxf.xml)的内容放入其中? - Abhijith Nagarajan
对于新手来说,停止混合使用 Spring 版本... 要么使用 2.5.6 或 3.1.1,但不要混合使用 JAR 包... 此外,spring.jar 已经包含了 spring-*.jars 的所有内容(在 Spring 3 之后不存在了)。 - M. Deinum
2个回答

2

我在运行时遇到了同样的异常。经过一天的研究,我发现我的项目正在使用最新的Spring 2.5.6版本,而我的Spring-jdbc却是3.2.2.RELEASE版本。由于我在使用一些不在2.5.6版本中的功能,因此无法使用Spring-jdbc 2.5.6。我解决这个问题的方法很简单,就是将spring-jdbc-3.2.2.RELEASE.jar放在CLASSPATH中spring-2.5.6.jar的前面。异常消失了。希望对一些人有帮助。


2

在从Java 6升级到7时,我们遇到了完全相同的问题,结果发现是commons-pool版本的问题。将其从 commons-pool-1.5.7.jar 更改为 commons-pool-1.6.jar 一切都正常了。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接