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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19022458/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 13:27:57  来源:igfitidea点击:

java.lang.reflect.MalformedParameterizedTypeException when deploying war file in Tomcat

javaspringweb-services

提问by user1688123

I'm getting the below exception when deploying through tomcat version 7.0.4. I'm using java 1.7. Seems like it is working with jdk 1.6 properly though.

通过 tomcat 7.0.4 版进行部署时出现以下异常。我正在使用 Java 1.7。似乎它可以正常使用 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.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.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)

Had googled and found out that it has to do with version conflicts with spring jars.

用谷歌搜索并发现它与spring jars的版本冲突有关。

I'm using the following spring jars.

我正在使用以下弹簧罐。

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

Tried by replacing spring-aop-2.5.6, spring-beans-2.5.6, spring-context-2.5.6 ,spring-core-2.5.6 with 3.1.1 also. Didnt help.

也尝试将 spring-aop-2.5.6、spring-beans-2.5.6、spring-context-2.5.6、spring-core-2.5.6 替换为 3.1.1。没有帮助。

Had tried deleting metadata and checking out fresh project, clean build, etc.. but nothing seems to work. Could someone show me the way out of this. Stuck with it for two days.

曾尝试删除元数据并检查新项目、干净构建等。但似乎没有任何效果。有人能告诉我摆脱这种情况的方法吗?坚持了两天。

回答by Kevin

I got the same exception at running time. After one day of research, I found my project is using spring 2.5.6. , which is the latest revision while my spring-jdbc is on 3.2.2.RELEASE. I am not able to use spring-jdbc 2.5.6 as I am using some of features that are not available in 2.5.6. The way I solved this problem is simply moving spring-jdbc-3.2.2.RELEASE.jar ahead of spring-2.5.6.jar in CLASSPATH. The exception went way. Hope this is helpful to some folks out there.

我在运行时遇到了同样的异常。经过一天的研究,我发现我的项目使用的是 spring 2.5.6。,这是最新版本,而我的 spring-jdbc 在 3.2.2.RELEASE 上。我无法使用 spring-jdbc 2.5.6,因为我正在使用 2.5.6 中没有的一些功能。我解决这个问题的方法是简单地将 spring-jdbc-3.2.2.RELEASE.jar 移动到 CLASSPATH 中的 spring-2.5.6.jar 之前。异常顺利。希望这对那里的一些人有所帮助。

回答by Dylan

We had this exact same issue when moving from java 6 -> 7 and it turned out to be the commons-pool version. Changed it from commons-pool-1.5.7.jar to commons-pool-1.6.jar and all was fine.

从 java 6 -> 7 迁移时,我们遇到了完全相同的问题,结果是 commons-pool 版本。将其从 commons-pool-1.5.7.jar 更改为 commons-pool-1.6.jar 一切正常。