AnnotationSessionFactoryBean需要lucene类

时间:2010-10-26 21:20:58

标签: java spring hibernate lucene hibernate-search

我正在尝试通过spring transaction向现有的webapp添加事务支持。

我最近将会话工厂类从LocalSessionFactoryBean更改为AnnotationSessionFactoryBean。

现在,当webapp启动时,我收到以下错误:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'txManager' defined in class path resource [context.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [context.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/apache/lucene/analysis/standard/StandardAnalyzer
 at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:275)
 at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1245)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
 at java.security.AccessController.doPrivileged(Native Method)

所以根本原因

nested exception is java.lang.NoClassDefFoundError: org/apache/lucene/analysis/standard/StandardAnalyzer

我不明白为什么现在我需要在我的webapp中加入lucene。我不打算将它用于搜索,我发现这个错误似乎非常错误。

1 个答案:

答案 0 :(得分:2)

没有看到完整的痕迹,我无法确定,但我的猜测是,这与Hibernate Search有关,后者使用Lucene。

AnnotationSessionFactoryBean将尝试在类路径上自动检测Hibernate Search的存在,如果找到则会初始化它。根据您的环境,它可能会在找不到Lucene之前到目前为止。

在你的类路径上有一个grub,看看是否有Hibernate Search,看看你是否可以删除它。另一种选择是将hibernate.search.autoregister_listeners hibernate属性设置为false,这应该明确禁用Hibernate Search的注册。