我在运行tomcat时遇到异常。
引起:java.lang.ClassCastException:org.hibernate.dialect.MySQLDialect无法强制转换为org.hibernate.dialect.Dialect
pom.xml中的我只为hibernate添加了以下依赖
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.1.0.Final</version>
</dependency>
我正在将我的项目spring mvc从3迁移到4。
因为我正在使用以下版本
<org.springframework.version>4.0.3.RELEASE</org.springframework.version>
<spring.version>4.0.2.RELEASE</spring.version>
你可以告诉我为什么我要面对这个问题吗?
下面是完整的错误堆栈
7005 ERROR DispatcherServlet - 上下文初始化失败
org.springframework.beans.factory.BeanCreationException:使用名称&#39; allocationDao&#39;创建bean时出错:资源依赖注入失败;嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名称为&#39; sessionFactory&#39;的bean时出错在类路径资源[net / nash / probase / probase-core-spring-config.xml]中定义:init方法的调用失败;嵌套异常是org.hibernate.HibernateException:无法实例化dialect类
在org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:307)
在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185)
在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory $ 1.getObject(AbstractBeanFactory.java:304)
在org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
在org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
在org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:700)
在org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
在org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:658)
在org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:624)
在org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:672)
在org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:543)
在org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:484)
在org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
在javax.servlet.GenericServlet.init(GenericServlet.java:158)
在org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1284)
在org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1197)
在org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1087)
在org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5210)
在org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5493)
在org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
在org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
在org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
在org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)
在org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1073)
在org.apache.catalina.startup.HostConfig $ DeployWar.run(HostConfig.java:1857)
at java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:471)
在java.util.concurrent.FutureTask.run(FutureTask.java:262)
在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:615)
在java.lang.Thread.run(Thread.java:745)
引起:org.springframework.beans.factory.BeanCreationException:创建名称为&#39; sessionFactory&#39;的bean时出错在类路径资源[net / nash / probase / probase-core-spring-config.xml]中定义:init方法的调用失败;嵌套异常是org.hibernate.HibernateException:无法实例化dialect类
在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1553)
在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory $ 1.getObject(AbstractBeanFactory.java:304)
在org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
在org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
在org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
在org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:445)
在org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:419)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor $ ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:544)
在org.springframework.beans.factory.annotation.InjectionMetadata $ InjectedElement.inject(InjectionMetadata.java:164)
在org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:304)
......还有33个
引起:org.hibernate.HibernateException:无法实例化dialect类
在org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.constructDialect(DialectFactoryImpl.java:82)
在org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:64)
在org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:146)
在org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)
在org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:71)
在org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2273)
在org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2269)
在org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSettings(LocalSessionFactoryBuilder.java:314)
在org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1738)
在org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1778)
在org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:343)
在org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:431)
在org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:416)
在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1612)
在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549)
......还有45个
引起:java.lang.ClassCastException:org.hibernate.dialect.MySQLDialect无法强制转换为org.hibernate.dialect.Dialect
在org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.constructDialect(DialectFactoryImpl.java:73)
......还有61个