最近改版了一个项目,只换了数据库,修改了数据库连接池配置文件和jar包后,项目不启动,报错如下:
2015-03-11 09:36:12.385 [main] ERROR org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'caseService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.kkmy.business.service.KkmyOrderService com.kkmy.business.service.CaseService.kkmyOrderService; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.jzt.business.datasource.DynamicDataSource] for bean with name 'dataSource' defined in URL [file:/C:/software/apache-tomcat-6.0.36/webapps/kkmyInterfaceClint/WEB-INF/classes/spring/applicationContext-dataSource.xml]; nested exception is java.lang.ClassNotFoundException: com.jzt.business.datasource.DynamicDataSource
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:288) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1116) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:628) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) ~[spring-context-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479) ~[spring-context-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389) ~[spring-web-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294) ~[spring-web-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112) [spring-web-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206) [catalina.jar:6.0.36]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705) [catalina.jar:6.0.36]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799) [catalina.jar:6.0.36]
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779) [catalina.jar:6.0.36]
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601) [catalina.jar:6.0.36]
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1079) [catalina.jar:6.0.36]
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1002) [catalina.jar:6.0.36]
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:506) [catalina.jar:6.0.36]
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317) [catalina.jar:6.0.36]
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324) [catalina.jar:6.0.36]
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142) [catalina.jar:6.0.36]
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065) [catalina.jar:6.0.36]
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840) [catalina.jar:6.0.36]
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057) [catalina.jar:6.0.36]
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463) [catalina.jar:6.0.36]
at org.apache.catalina.core.StandardService.start(StandardService.java:525) [catalina.jar:6.0.36]
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754) [catalina.jar:6.0.36]
at org.apache.catalina.startup.Catalina.start(Catalina.java:595) [catalina.jar:6.0.36]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_04]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_04]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_04]
at java.lang.reflect.Method.invoke(Method.java:601) ~[na:1.7.0_04]
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) [bootstrap.jar:6.0.36]
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) [bootstrap.jar:6.0.36]
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.kkmy.business.service.KkmyOrderService com.kkmy.business.service.CaseService.kkmyOrderService; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.jzt.business.datasource.DynamicDataSource] for bean with name 'dataSource' defined in URL [file:/C:/software/apache-tomcat-6.0.36/webapps/kkmyInterfaceClint/WEB-INF/classes/spring/applicationContext-dataSource.xml]; nested exception is java.lang.ClassNotFoundException: com.jzt.business.datasource.DynamicDataSource
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:514) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
... 37 common frames omitted
Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.jzt.business.datasource.DynamicDataSource] for bean with name 'dataSource' defined in URL [file:/C:/software/apache-tomcat-6.0.36/webapps/kkmyInterfaceClint/WEB-INF/classes/spring/applicationContext-dataSource.xml]; nested exception is java.lang.ClassNotFoundException: com.jzt.business.datasource.DynamicDataSource
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1275) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:575) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1344) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:355) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:334) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.BeanFactoryUtils.beanNamesForTypeIncludingAncestors(BeanFactoryUtils.java:187) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:897) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:855) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:770) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:486) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
... 39 common frames omitted
Caused by: java.lang.ClassNotFoundException: com.jzt.business.datasource.DynamicDataSource
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680) ~[catalina.jar:6.0.36]
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526) ~[catalina.jar:6.0.36]
at org.springframework.util.ClassUtils.forName(ClassUtils.java:260) ~[spring-core-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:416) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1296) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
------解决思路----------------------
Cannot find class [com.jzt.business.datasource.DynamicDataSource] for bean with name 'dataSource' defined in URL [file:/C:/software/apache-tomcat-6.0.36/webapps/kkmyInterfaceClint/WEB-INF/classes/spring/applicationContext-dataSource.xml]
------解决思路----------------------
sqlserver 的驱动包没有加载。检查你的运行时环境
------解决思路----------------------
Microsoft JDBC Driver for SQL Server
的下载地址:
https://msdn.microsoft.com/en-us/sqlserver/aa937724.aspx