简体   繁体   English

升级到Hibernate 5时,SessionFactoryImpl中的AbstractMethodError

[英]AbstractMethodError in SessionFactoryImpl when upgrading to Hibernate 5

We're using Spring ORM 4.2.1.RELEASE to interact with Hibernate via JPA. 我们使用Spring ORM 4.2.1.RELEASE通过JPA与Hibernate交互。 Everything works fine with Hibernate 4.3.11.Final, but when we try to upgrade to Hibernate 5, it breaks with an AbstractMethodError when constructing the SessionFactory. Hibernate 4.3.11.Final一切正常,但是当我们尝试升级到Hibernate 5时,它在构造SessionFactory时会出现AbstractMethodError。

According to the release notes, Spring 4.2.1 does support Hibernate 5. Examining the Maven dependency tree didn't show any duplicate or obsolete versions of Hibernate or Spring. 根据发行说明,Spring 4.2.1确实支持Hibernate 5.检查Maven依赖树没有显示任何重复或过时的Hibernate或Spring版本。 The specific line that is reported ( https://github.com/hibernate/hibernate-orm/blob/master/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java line 278) is iterating over Hibernate integrators, but we don't use any, so the list of integrators should logically be empty (and thus not iterate). 报告的具体行( https://github.com/hibernate/hibernate-orm/blob/master/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java第278行)正在迭代Hibernate集成商,但我们不使用任何集成商,因此集成商列表在逻辑上应该是空的(因此不会迭代)。

Does anyone know whether this is a bug (or lack of support) in Spring, or if we're doing something wrong? 有没有人知道这是春天的错误(或缺乏支持),还是我们做错了什么?

Extract from application log: 从应用程序日志中提取:

2015-09-08 13:17:45,452 [main] INFO  org.springframework.test.context.support.DefaultTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@20f0461e, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@7e8b6c76, org.springframework.test.context.support.DependencyInjectionTestExecutionListener@737df7e1, org.springframework.test.context.support.DirtiesContextTestExecutionListener@531d1003, org.springframework.test.context.transaction.TransactionalTestExecutionListener@19065f96, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@716d7daf]
2015-09-08 13:17:45,460 [main] INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [dataContext.xml]
2015-09-08 13:17:45,689 [main] INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [systemContext.xml]
2015-09-08 13:17:45,779 [main] INFO  org.springframework.context.support.GenericApplicationContext - Refreshing org.springframework.context.support.GenericApplicationContext@4b56a656: startup date [Tue Sep 08 13:17:45 AEST 2015]; root of context hierarchy
2015-09-08 13:17:45,846 [main] INFO  org.springframework.context.support.PropertySourcesPlaceholderConfigurer - Loading properties file from class path resource [application.properties]
2015-09-08 13:17:45,900 [MLog-Init-Reporter] INFO  com.mchange.v2.log.MLog - MLog clients using slf4j logging.
2015-09-08 13:17:45,921 [main] INFO  com.mchange.v2.c3p0.C3P0Registry - Initializing c3p0-0.9.5.1 [built 16-June-2015 00:06:36 -0700; debug? true; trace: 10]
2015-09-08 13:17:46,046 [main] INFO  org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean - Building JPA container EntityManagerFactory for persistence unit 'default'
2015-09-08 13:17:46,060 [main] INFO  org.hibernate.jpa.internal.util.LogHelper - HHH000204: Processing PersistenceUnitInfo [
    name: default
    ...]
2015-09-08 13:17:46,136 [main] INFO  org.hibernate.Version - HHH000412: Hibernate Core {5.0.1.Final}
2015-09-08 13:17:46,137 [main] INFO  org.hibernate.cfg.Environment - HHH000206: hibernate.properties not found
2015-09-08 13:17:46,138 [main] INFO  org.hibernate.cfg.Environment - HHH000021: Bytecode provider name : javassist
2015-09-08 13:17:46,166 [main] INFO  org.hibernate.annotations.common.Version - HCANN000001: Hibernate Commons Annotations {5.0.0.Final}
2015-09-08 13:17:46,274 [main] INFO  com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource - Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, contextClassLoaderSource -> caller, dataSourceName -> z8kfsx9b1bfny2k11h75wx|4aa092d5, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> org.hsqldb.jdbcDriver, extensions -> {}, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, forceSynchronousCheckins -> false, forceUseNamedDriverClass -> false, identityToken -> z8kfsx9b1bfny2k11h75wx|4aa092d5, idleConnectionTestPeriod -> 30, initialPoolSize -> 3, jdbcUrl -> jdbc:hsqldb:mem:testDB, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 0, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 15, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 3, numHelperThreads -> 3, preferredTestQuery -> null, privilegeSpawnedThreads -> false, properties -> {user=******, password=******}, propertyCycle -> 0, statementCacheNumDeferredCloseThreads -> 0, testConnectionOnCheckin -> true, testConnectionOnCheckout -> true, unreturnedConnectionTimeout -> 0, userOverrides -> {}, usesTraditionalReflectiveProxies -> false ]
2015-09-08 13:17:46,396 [main] INFO  org.hibernate.dialect.Dialect - HHH000400: Using dialect: org.hibernate.dialect.HSQLDialect
2015-09-08 13:17:46,429 [main] INFO  org.hibernate.engine.jdbc.env.internal.LobCreatorBuilderImpl - HHH000423: Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4
2015-09-08 13:17:46,592 [main] WARN  org.springframework.context.support.GenericApplicationContext - Exception encountered during context initialization - cancelling refresh attempt
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [dataContext.xml]: Invocation of init method failed; nested exception is java.lang.AbstractMethodError
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578) ~[spring-beans-4.2.1.RELEASE.jar:4.2.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) ~[spring-beans-4.2.1.RELEASE.jar:4.2.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.1.RELEASE.jar:4.2.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:305) ~[spring-beans-4.2.1.RELEASE.jar:4.2.1.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.1.RELEASE.jar:4.2.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:301) ~[spring-beans-4.2.1.RELEASE.jar:4.2.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196) ~[spring-beans-4.2.1.RELEASE.jar:4.2.1.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1045) ~[spring-context-4.2.1.RELEASE.jar:4.2.1.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:824) ~[spring-context-4.2.1.RELEASE.jar:4.2.1.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537) [spring-context-4.2.1.RELEASE.jar:4.2.1.RELEASE]
    at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:125) [spring-test-4.2.1.RELEASE.jar:4.2.1.RELEASE]
    ... rows deleted
Caused by: java.lang.AbstractMethodError
    at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:278) ~[hibernate-core-5.0.1.Final.jar:5.0.1.Final]
    at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:444) ~[hibernate-core-5.0.1.Final.jar:5.0.1.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:802) ~[hibernate-entitymanager-5.0.1.Final.jar:5.0.1.Final]
    at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60) ~[spring-orm-4.2.1.RELEASE.jar:4.2.1.RELEASE]
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:343) ~[spring-orm-4.2.1.RELEASE.jar:4.2.1.RELEASE]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:318) ~[spring-orm-4.2.1.RELEASE.jar:4.2.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637) ~[spring-beans-4.2.1.RELEASE.jar:4.2.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) ~[spring-beans-4.2.1.RELEASE.jar:4.2.1.RELEASE]
    ... 41 more

Extract from Spring context: 从Spring上下文中提取:

<bean id="jpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"/>

<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="dataSource" ref="dataSource"/>
    <property name="jpaVendorAdapter" ref="jpaVendorAdapter"/>
    <property name="packagesToScan" value="au.gov.qld.ssq.cofa.domain"/>
    <property name="jpaPropertyMap">
        <map>
            <entry key="hibernate.dialect" value="${hibernate.dialect}"/>
            <entry key="hibernate.show_sql" value="${hibernate.show_sql}"/>
            <entry key="hibernate.hbm2ddl.auto" value="${hibernate.hbm2ddl.auto}"/>
        </map>
    </property>
</bean>

This error has nothing to do with Spring. 这个错误与Spring无关。 You have an Hibernate 5 incompatible Integrator in your classpath. 你的类路径中有一个Hibernate 5不兼容的Integrator These are detected through the ServiceRegistry. 这些是通过ServiceRegistry检测到的。

A common issue is older versions of Jadira Usertype which is not compatible with Hibernate 5. If you have Jadira User type prior to version 5.0.0 in your classpath you will get this exception. 常见问题是旧版本的Jadira Usertype与Hibernate 5不兼容。如果在类路径中有5.0.0之前的Jadira用户类型,则会出现此异常。 If that is not the case for you, and you are unsure of which library you are having an issue with, put a breakpoint on line 278 of SessionFactoryImpl and check out the class of the Integrator that causes the exception. 如果您不是这种情况,并且您不确定哪个库存在问题,请在SessionFactoryImpl的第278行放置一个断点并检查导致该异常的Integrator类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 org.hibernate.internal.SessionFactoryImpl抛出的AbstractMethodError。 <init> 从Spring Boot 1.3升级到1.4 RC1时 - AbstractMethodError thrown by org.hibernate.internal.SessionFactoryImpl.<init> when upgrading from Spring Boot 1.3 to 1.4 RC1 执行“org.hibernate.internal.SessionFactoryImpl()”构造函数时发生“AbstractMethodError”错误 - The "AbstractMethodError" error occurred while executing the "org.hibernate.internal.SessionFactoryImpl()" constructor 升级到Hibernate 3.3.2后出现java.lang.AbstractMethodError - java.lang.AbstractMethodError after upgrading to Hibernate 3.3.2 休眠AbstractMethodError - Hibernate AbstractMethodError 将Jersey客户端1.x升级到2.x时,UriBuilder上的AbstractMethodError - AbstractMethodError on UriBuilder when upgrading Jersey client 1.x to 2.x 使用Jadiru Joda /休眠永久用户类型时的AbstractMethodError - AbstractMethodError when using Jadiru Joda/Hibernate persistent user types 休眠更新后的 AbstractMethodError - AbstractMethodError after hibernate update 如何解决Hibernate 5中的AbstractMethodError? - How to solve AbstractMethodError in Hibernate 5? org.hibernate.impl.SessionFactoryImpl对象的正常大小是多少? - What would be a normal size of org.hibernate.impl.SessionFactoryImpl objects ? 如何释放多个org.hibernate.impl.SessionFactoryImpl - How to release multiple org.hibernate.impl.SessionFactoryImpl
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM