问题描述
- org.springframework.beans.TypeMismatchException
-
eclipse启动没问题,打成war包,放在tomcat中直接启动就报这个错。严重: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'activityDao' defined in file [F:workapache-tomcat-7.0.52webappsluckeysWEB-INFclassescomluckeysdaoActivityDao.class]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'java.lang.String' to required type 'java.lang.Class' for property 'mapperInterface'; nested exception is java.lang.IllegalArgumentException: Error loading class [com.luckeys.dao.ActivityDao]: problem with class file or dependent class.
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:547)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:684)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1073)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'java.lang.String' to required type 'java.lang.Class' for property 'mapperInterface'; nested exception is java.lang.IllegalArgumentException: Error loading class [com.luckeys.dao.ActivityDao]: problem with class file or dependent class.
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:479)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:511)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:505)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1502)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1461)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1197)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
... 25 more
Caused by: java.lang.IllegalArgumentException: Error loading class [com.luckeys.dao.ActivityDao]: problem with class file or dependent class.
at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:286)
at org.springframework.beans.propertyeditors.ClassEditor.setAsText(ClassEditor.java:63)
at org.springframework.beans.TypeConverterDelegate.doConvertTextValue(TypeConverterDelegate.java:430)
at org.springframework.beans.TypeConverterDelegate.doConvertValue(TypeConverterDelegate.java:403)
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:181)
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:459)
... 31 more
Caused by: java.lang.UnsupportedClassVersionError: com/luckeys/dao/ActivityDao : Unsupported major.minor version 51.0 (unable to load class com.luckeys.dao.ActivityDao)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2948)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1208)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1688)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1569)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:247)
at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:280)
... 36 more
2015-10-24 9:59:32 org.apache.catalina.core.StandardContext startInternal
严重: Error listenerStart
2015-10-24 9:59:32 org.apache.catalina.core.StandardContext startInternal
严重: Context [/luckeys] startup failed due to previous errors
2015-10-24 9:59:32 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/luckeys] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak.
2015-10-24 9:59:32 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/luckeys] appears to have started a thread named [Atomikos:0] but has failed to stop it. This is very likely to create a memory leak.
解决方案
用SSH做web开发的经常遇到以下问题:
org.springframework.beans.TypeMismatchException: Failed to convert property value of type [com.kgjia.admin.service.impl.ShopTypeServiceImpl$$EnhancerByCGLIB$$6af677d9] to required type [com.kgjia.admin.service.IShopTypeServi......
答案就在这里:org.springframework.beans.TypeMismatchException:
----------------------
解决方案二:
已经解决了。是我eclipse的编译环境是1.7.但是tomcat是1.6.
所以报出了该错误。