首先,我通常不使用Java,但在過去,所以我有點出我的舒適區。我有一個我正在開發的Spring和Hibernate項目,它在啓動時有一個致命錯誤。我可以克隆這個相同的repo到另一臺Macbook Pro(和這個一樣)並導入到eclipse中,maven clean install,在服務器上運行(tomcat config)並且它可以工作。Maven/Spring/Hibernate NoSuchMethodError:org.hibernate.engine.jdbc.spi.JdbcServices.getConnectionProvider()
Jan 20, 2016 3:45:34 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mssqlEntityManagerFactory' defined in class path resource [applicationContext-mssql.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.hibernate.engine.jdbc.spi.JdbcServices.getConnectionProvider()Lorg/hibernate/engine/jdbc/connections/spi/ConnectionProvider;
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:529)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:198)
at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:741)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:410)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5003)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5517)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1574)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1564)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mssqlEntityManagerFactory' defined in class path resource [applicationContext-mssql.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.hibernate.engine.jdbc.spi.JdbcServices.getConnectionProvider()Lorg/hibernate/engine/jdbc/connections/spi/ConnectionProvider;
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1512)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:198)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:438)
at org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors(BeanFactoryUtils.java:277)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.detectPersistenceExceptionTranslators(PersistenceExceptionTranslationInterceptor.java:139)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.<init>(PersistenceExceptionTranslationInterceptor.java:79)
at org.springframework.dao.annotation.PersistenceExceptionTranslationAdvisor.<init>(PersistenceExceptionTranslationAdvisor.java:71)
at org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor.setBeanFactory(PersistenceExceptionTranslationPostProcessor.java:84)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1532)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1500)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
... 19 more
Caused by: java.lang.NoSuchMethodError: org.hibernate.engine.jdbc.spi.JdbcServices.getConnectionProvider()Lorg/hibernate/engine/jdbc/connections/spi/ConnectionProvider;
at org.jadira.usertype.spi.shared.AbstractUserTypeHibernateIntegrator.use42Api(AbstractUserTypeHibernateIntegrator.java:80)
at org.jadira.usertype.spi.shared.AbstractUserTypeHibernateIntegrator.integrate(AbstractUserTypeHibernateIntegrator.java:61)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:306)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1744)
at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:94)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:905)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:890)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:74)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:290)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:310)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1571)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1509)
... 34 more
的Tomcat 7.0.64
的Maven的依賴關係樹
$ mvn dependency:tree
[INFO] +- commons-lang:commons-lang:jar:2.4:compile
[INFO] +- commons-codec:commons-codec:jar:1.6:compile
[INFO] +- javax.servlet:servlet-api:jar:2.5:provided
[INFO] +- org.springframework.ldap:spring-ldap-core:jar:2.0.2.RELEASE:compile
[INFO] | +- org.springframework.data:spring-data-commons:jar:1.6.1.RELEASE:compile
[INFO] | \- org.springframework:spring-beans:jar:3.2.8.RELEASE:compile
[INFO] +- org.springframework.ldap:spring-ldap-odm:jar:2.0.2.RELEASE:compile
[INFO] | +- org.freemarker:freemarker:jar:2.3.9:compile
[INFO] | +- commons-cli:commons-cli:jar:1.2:compile
[INFO] | \- org.springframework.ldap:spring-ldap-core-tiger:jar:2.0.2.RELEASE:compile
[INFO] +- joda-time:joda-time:jar:2.5:compile
[INFO] +- org.apache.commons:commons-math3:jar:3.3:compile
[INFO] +- org.apache.commons:commons-collections4:jar:4.0:compile
[INFO] +- org.jadira.usertype:usertype.core:jar:3.2.0.GA:compile
[INFO] | +- org.slf4j:slf4j-api:jar:1.7.6:compile
[INFO] | \- org.jadira.usertype:usertype.spi:jar:3.2.0.GA:compile
[INFO] +- com.mandrillapp.wrapper.lutung:lutung:jar:0.0.4:compile
[INFO] | +- com.google.code.gson:gson:jar:2.2.2:compile
[INFO] | \- org.apache.commons:commons-io:jar:1.3.2:compile
[INFO] +- org.springframework.security:spring-security-core:jar:3.2.3.RELEASE:compile
[INFO] | +- aopalliance:aopalliance:jar:1.0:compile
[INFO] | +- org.springframework:spring-aop:jar:3.2.8.RELEASE:compile
[INFO] | \- org.springframework:spring-expression:jar:3.2.8.RELEASE:compile
[INFO] +- org.springframework.security:spring-security-config:jar:3.2.3.RELEASE:compile
[INFO] +- org.springframework.security:spring-security-ldap:jar:3.2.3.RELEASE:compile
[INFO] +- org.springframework.security.oauth:spring-security-oauth2:jar:2.0.5.RELEASE:compile
[INFO] | \- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.13:compile
[INFO] | \- org.codehaus.jackson:jackson-core-asl:jar:1.9.13:compile
[INFO] +- org.springframework.ws:spring-ws-core:jar:2.1.4.RELEASE:compile
[INFO] | +- org.springframework.ws:spring-xml:jar:2.1.4.RELEASE:compile
[INFO] | +- wsdl4j:wsdl4j:jar:1.6.1:compile
[INFO] | \- javax.xml.stream:stax-api:jar:1.0-2:compile
[INFO] +- org.springframework:spring-oxm:jar:3.2.4.RELEASE:compile
[INFO] +- org.slf4j:jcl-over-slf4j:jar:1.7.6:compile
[INFO] +- org.slf4j:log4j-over-slf4j:jar:1.7.6:compile
[INFO] +- org.slf4j:jul-to-slf4j:jar:1.7.6:compile
[INFO] +- ch.qos.logback:logback-classic:jar:1.1.2:compile
[INFO] | \- ch.qos.logback:logback-core:jar:1.1.2:compile
[INFO] \- org.glassfish.jersey.media:jersey-media-multipart:jar:2.15:compile
[INFO] +- org.glassfish.jersey.core:jersey-common:jar:2.15:compile
[INFO] | +- javax.annotation:javax.annotation-api:jar:1.2:compile
[INFO] | +- org.glassfish.jersey.bundles.repackaged:jersey-guava:jar:2.15:compile
[INFO] | \- org.glassfish.hk2:osgi-resource-locator:jar:1.0.1:compile
[INFO] \- org.jvnet.mimepull:mimepull:jar:1.9.3:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1:49.357s
[INFO] Finished at: Thu Jan 21 11:15:00 EST 2016
[INFO] Final Memory: 18M/307M
[INFO] ------------------------------------------------------------------------
Maven的
$ mvn -v
Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 08:51:28-0500)
Maven home: /usr/local/maven
Java version: 1.8.0_60, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.9.5", arch: "x86_64", family: "mac"
的Java
$ java -version
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
我採取了以下措施:
$ git clone http://github.com/repo
$ cd repo
$ git checkout branch
$ mvn clean install
我部署到Tomcat Web GUI中,它不會啓動。 我清理了repo重建的所有東西,並且完全從Eclipse內部嘗試,甚至讓它處理Tomcat,我也得到了相同的結果。我在清理時多次刪除了〜/ .m2/repository文件夾,並且總是出現相同的錯誤。
在另一臺機器上偶爾會出現這個錯誤,並且一個乾淨的安裝會修復它。另一臺機器運行Maven 3.3.3和Java 1.7.0_79。
任何幫助將不勝感激。
這可能有所幫助:http://stackoverflow.com/questions/23018179/hibernate-4-connectionprovider-class-not-found –
您可以添加'''mvn dependency:tree'''輸出到你的文章。 –
謝謝,我們是博格,在我的搜索過程中我閱讀過這篇文章,現在我會再讀一次。一切都指向春季和休眠之間的版本不匹配,但我可以在另一臺機器上運行確切的設置,它的工作原理是最令我困惑的是什麼。 Karthikeyan我在問我現在是否可以發佈該輸出。 – noahtkeller