我正在嘗試一個簡單的Hibernate分片示例(Yes,odd,3.0.0 .Beta2使用Hibernate 4.1.7核心和Spring 3.1.2發佈了4年前)和會話工廠初始化期間打這個問題:我如何挑選Spring和Hibernatejava.lang.NoClassDefFoundError:來自Spring 3.1.2/Hibernate 4.1.7的org/hibernate/engine/SessionFactoryImplementor和Shards 3.0.0.Beta2
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)
這就是:
<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>
這看起來不像碎片庫的問題 - 它看起來像是由重構的Sessio引起的一般問題nFactoryImplementor類。參考https://jira.springsource.org/browse/SPR-8885,我也切換到bean'transactionmanager'的org.springframework.orm.hibernate4.HibernateTransactionManager - 它沒有幫助。
Spring 3.x和Hibernate 4.x有沒有什麼功能解決方法?
從嘗試了答案:http://stackoverflow.com/questions/9908452/java-lang -classnotfoundexception-org-hibernate-engine-sessionfactoryimplementor – 2014-02-21 13:45:12