gpt4 book ai didi

spring - java.lang.NoClassDefFoundError : org/hibernate/engine/SessionFactoryImplementor from Spring 3. 1.2/Hibernate 4.1.7 和 Shards 3.0.0.Beta2

转载 作者:行者123 更新时间:2023-12-02 04:10:14 26 4
gpt4 key购买 nike

我正在使用 Hibernate Core 4.1.7 和 Spring 3.1.2 尝试一个简单的 Hibernate 分片示例(是的,奇怪,4 年前发布的 3.0.0.Beta2),并在 session 工厂初始化期间遇到了这个问题:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mySessionFactory' defined in class path resource [shardedspring-config.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.hibernate.SessionFactory it.sella.lab.crm.sys.persistence.ShardedSessionFactoryBuilder.createSessionFactory()] threw exception; nested exception is java.lang.NoClassDefFoundError: org/hibernate/engine/SessionFactoryImplementor
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:581)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1015)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:911)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:609)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:469)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at in.rixx.crm.model.Activity.<clinit>(Activity.java:17)

这就是我选择 Spring 和 Hibernate 的方式:

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.1.7.Final</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.1.2.RELEASE</version>
</dependency>

这似乎不是分片库的问题 - 它看起来像是由重构的 SessionFactoryImplementor 类引起的一般问题。引用 https://jira.springsource.org/browse/SPR-8885 ,我还为 bean 'transactionmanager' 切换到 org.springframework.orm.hibernate4.HibernateTransactionManager - 它没有帮助。

目前 Spring 3.x 和 Hibernate 4.x 有任何功能性解决方法吗?

最佳答案

I too faced the same issue i searched some other sites and its helped me to resolve this issue.What i done wrong is hibernate version i used 4 in maven for transaction manager but in the maven i am configuring the hibernate transaction manager of version 3, that's incompatibility. I changed the spring configuration file like this.

<bean id="hibernateTransactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- <bean id="hibernateTransactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean> -->

关于spring - java.lang.NoClassDefFoundError : org/hibernate/engine/SessionFactoryImplementor from Spring 3. 1.2/Hibernate 4.1.7 和 Shards 3.0.0.Beta2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13072690/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com