Hibernate Search 4.1.1 NoSuchMethodError FSDirectory.open

时间:2012-06-11 21:36:57

标签: lucene hibernate-search

我正在尝试使用Hibernate-Search 4.1.1-Final + Lucene 3.5与Hibernate 4.1.3和Spring 3.1.1框架(使用Maven的依赖)来启用基于POJO的文本搜索。我按照Hibernate-Search文档。基于doc,这是我的Hibernate配置:

    <bean id="sessionFactory"
    class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
            <property name="dataSource" ref="dataSource" />
    <property name="mappingResources">
        <list>
            <value>com/mytutorial/User.hbm.xml</value>
                     </list>
    </property>
    <property name="hibernateProperties">
        <props>
            <!-- Other Hibernate-specific properties -->
            <prop key="hibernate.search.default.directory_provider">filesystem</prop>
            <prop key="hibernate.search.default.indexBase">C:/temp/</prop>
            <prop key="hibernate.search.lucene_version">LUCENE_35</prop>
         </props>
    </property>
</bean>

我打开了hibernate-search的日志(DEBUG),显示:

[INFO,Version,pool-2-thread-1] HSEARCH000034: Hibernate Search 4.1.1.Final
[DEBUG,ConfigContext,pool-2-thread-1] Setting Lucene compatibility to Version LUCENE_35
[DEBUG,ConfigContext,pool-2-thread-1] Using default similarity implementation: org.apache.lucene.search.DefaultSimilarity
[WARN,DirectoryProviderHelper,pool-2-thread-1] HSEARCH000041: Index directory not found, creating: 'C:\temp\com.mytutorial.User'

在创业公司。之后,当我在Windows 7 64位计算机上运行tomcat服务器时,出现以下异常。

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/config/spring/application-context.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.apache.lucene.store.FSDirectory.open(Ljava/io/File;Lorg/apache/lucene/store/LockFactory;)Lorg/apache/lucene/store/FSDirectory;
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    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.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
    ... 45 more
Caused by: java.lang.NoSuchMethodError: org.apache.lucene.store.FSDirectory.open(Ljava/io/File;Lorg/apache/lucene/store/LockFactory;)Lorg/apache/lucene/store/FSDirectory;
    at org.hibernate.search.store.impl.DirectoryProviderHelper$FSDirectoryType.getDirectory(DirectoryProviderHelper.java:365)
    at org.hibernate.search.store.impl.DirectoryProviderHelper.createFSIndex(DirectoryProviderHelper.java:137)
    at org.hibernate.search.store.impl.FSDirectoryProvider.initialize(FSDirectoryProvider.java:70)
    at org.hibernate.search.store.impl.DirectoryProviderFactory.createDirectoryProvider(DirectoryProviderFactory.java:84)
    at org.hibernate.search.indexes.impl.DirectoryBasedIndexManager.createDirectoryProvider(DirectoryBasedIndexManager.java:216)
    at org.hibernate.search.indexes.impl.DirectoryBasedIndexManager.initialize(DirectoryBasedIndexManager.java:89)
    at org.hibernate.search.indexes.impl.IndexManagerHolder.createDirectoryManager(IndexManagerHolder.java:241)
    at org.hibernate.search.indexes.impl.IndexManagerHolder.buildEntityIndexBinding(IndexManagerHolder.java:111)
    at org.hibernate.search.spi.SearchFactoryBuilder.initDocumentBuilders(SearchFactoryBuilder.java:411)
    at org.hibernate.search.spi.SearchFactoryBuilder.buildNewSearchFactory(SearchFactoryBuilder.java:221)
    at org.hibernate.search.spi.SearchFactoryBuilder.buildSearchFactory(SearchFactoryBuilder.java:145)
    at org.hibernate.search.event.impl.FullTextIndexEventListener.initialize(FullTextIndexEventListener.java:129)
    at org.hibernate.search.hcore.impl.HibernateSearchIntegrator.integrate(HibernateSearchIntegrator.java:82)
    at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:306)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1744)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1782)
    at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:189)
    at org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:350)
    at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:335)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
    ... 52 more

即使我从配置中删除了“hibernate.search.lucene_version”属性,我仍然会遇到异常。

1 个答案:

答案 0 :(得分:0)

NoSuchMethodError 表示您的类路径中包含错误版本的Lucene。

您可能还想检查重复项,并使用命令行工具(如Tattletale)轻松查找类和库副本。