복붙노트

[SPRING] Hibernate 5로 업그레이드 할 때 SessionFactoryImpl의 AbstractMethodError

SPRING

Hibernate 5로 업그레이드 할 때 SessionFactoryImpl의 AbstractMethodError

Spring ORM 4.2.1.RELEASE를 사용하여 JPA를 통해 Hibernate와 상호 작용합니다. 모든 것이 Hibernate 4.3.11.Final에서 잘 작동하지만, 우리가 Hibernate 5로 업그레이드하려고 할 때, SessionFactory를 생성 할 때 AbstractMethodError로 깨진다.

릴리스 노트에 따르면, Spring 4.2.1은 Hibernate 5를 지원한다. Maven 의존성 트리를 조사해도 Hibernate 나 Spring의 중복되거나 쓸모없는 버전은 보이지 않는다. 보고 된 특정 줄 (https://github.com/hibernate/hibernate-orm/blob/master/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java 줄 278)은 반복됩니다. Hibernate integrator,하지만 우리는 어떤 것도 사용하지 않으므로, 적분기 목록은 논리적으로 비어 있어야하므로 반복하지 않아야합니다.

누구든지 이것이 봄에 버그 (또는 지원이 부족한 것)인지, 아니면 우리가 뭔가 잘못하고 있는지 알 수 있습니까?

응용 프로그램 로그에서 추출 :

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

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>

해결법

  1. ==============================

    1.이 오류는 Spring과 아무 관련이 없습니다. 클래스 패스에 Hibernate 5 호환되지 않는 Integrator가 있습니다. 이들은 ServiceRegistry를 통해 감지됩니다.

    이 오류는 Spring과 아무 관련이 없습니다. 클래스 패스에 Hibernate 5 호환되지 않는 Integrator가 있습니다. 이들은 ServiceRegistry를 통해 감지됩니다.

    일반적인 문제는 Hibernate 5와 호환되지 않는 이전 버전의 Jadira Usertype입니다. 클래스 패스에 5.0.0 이전 버전의 Jadira 사용자 유형이있는 경우이 예외가 발생합니다. 이것이 사실이 아니며 문제가있는 라이브러리가 확실하지 않은 경우 SessionFactoryImpl의 278 행에 중단 점을 배치하고 예외를 발생시키는 Integrator의 클래스를 확인하십시오.

  2. from https://stackoverflow.com/questions/32448957/abstractmethoderror-in-sessionfactoryimpl-when-upgrading-to-hibernate-5 by cc-by-sa and MIT license