0

Hibernate-Search 4.1.1-Final + Lucene 3.5 と Hibernate 4.1.3 および Spring 3.1.1 フレームワーク (Maven を使用した依存関係) を使用して、POJO ベースのテキスト検索を有効にしようとしています。Hibernate-Search のドキュメントに従いました。ドキュメントに基づいて、これが私の 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'

起動時に。その後、Tomcat サーバーを Windows 7 64 ビット マシンで実行すると、次の例外が発生します。

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」プロパティを削除しても、例外が発生します。

4

1 に答える 1

0

NoSuchMethodErrorは、クラスパスに間違ったバージョンの Lucene があることを意味します。

重複をチェックし、 Tattletaleなどのコマンド ライン ツールを使用して、クラスとライブラリの重複を簡単に見つけることもできます。

于 2012-06-25T23:07:57.267 に答える