我是编写一个使用Hibernate搜索的web应用程序的团队的一员,我们最近开始尝试使用JGroups来保持不同节点上的Lucene索引彼此同步。
但是,我无法完成设置这个过程的最基本的第一步,而且文档看起来像是quite sparse。
<bean class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" id="myFactory">
<property name="dataSource" ref="myDataSource"/>
<property name="persistenceXmlLocation" value="/WEB-INF/persistence.xml"/>
<property name="persistenceUnitName" value="persistenceUnit"/>
<property name="jpaVendorAdapter" ref="vendorAdapter"/>
<property name="jpaProperties">
<props>
<prop key="hibernate.search.worker.backend.jgroups.configurationFile">jgroups-config.xml</prop>
<prop key="hibernate.search.default.directory_provider">infinispan</prop>
<prop key="hibernate.search.default.indexBase">indexes</prop>
<prop key="hibernate.search.default.worker.backend">jgroups</prop>
<prop key="hibernate.search.services.jgroups.clusterName">MyCluster</prop>
<prop key="hibernate.search.error_handler">log</prop>
<prop key="hibernate.search.lucene_version">LUCENE_36</prop>
<prop key="hibernate.search.generate_statistics">true</prop>
<prop key="hibernate.search.jmx_enabled">true</prop>
</props>
</property>
这里的关键属性是hibernate.search.worker.backend.jgroups.configurationFile
,它提供了我们最终需要的jgroups配置文件的名称。我尝试将此文件放入WEB-INF中,并将其与JBoss模块目录结构中的props文件放在一起(其他文件位于该目录结构中并成功加载),但就是不能使用它。
在日志中,我可以看到:
16:34:57,609 INFO [org.hibernate.search.backend.impl.jgroups.JGroupsChannelProvider] (MSC service thread 1-1) HSEARCH000005: Starting JGroups Channel
16:34:57,609 INFO [org.hibernate.search.backend.impl.jgroups.JGroupsChannelProvider] (MSC service thread 1-1) HSEARCH000011: Unable to use any JGroups configuration mechanisms provided in properties { hibernate.search.default.worker.backend=jgroups, hibernate.search.default.directory_provider=infinispan, hibernate.search.worker.backend.jgroups.configurationFile=jgroups-config.xml}. Using default JGroups configuration file!
16:34:59,427 INFO [stdout] (MSC service thread 1-1)
16:34:59,427 INFO [stdout] (MSC service thread 1-1) -------------------------------------------------------------------
16:34:59,428 INFO [stdout] (MSC service thread 1-1) GMS: address=LDNLPT1271-PC-17149, cluster=CrisisHubCluster, physical address=172.26.10.169:58147
16:34:59,428 INFO [stdout] (MSC service thread 1-1) -------------------------------------------------------------------
16:35:02,448 INFO [org.hibernate.search.backend.impl.jgroups.JGroupsMasterMessageListener] (MSC service thread 1-1) HSEARCH000015: Received new cluster view: [LDNLPT1271-PC-17149|0] [LDNLPT1271-PC-17149]
16:35:02,450 INFO [org.hibernate.search.backend.impl.jgroups.JGroupsChannelProvider] (MSC service thread 1-1) HSEARCH000006: Connected to cluster [ MyCluster ]. The node address is LDNLPT1271-PC-17149
16:35:02,513 INFO [org.infinispan.remoting.transport.jgroups.JGroupsTransport] (CacheStartThread,HibernateSearch-Infinispan-cluster,LuceneIndexesMetadata) ISPN000078: Starting JGroups Channel
16:35:02,514 INFO [org.infinispan.remoting.transport.jgroups.JGroupsTransport] (CacheStartThread,HibernateSearch-Infinispan-cluster,LuceneIndexesMetadata) ISPN000088: Unable to use any JGroups configuration mechanisms provided in properties {}. Using default JGroups configuration!
我已经截断了Unable to use any JGroups configuration mechanisms provided in properties
中的属性列表,因为它将占用几个页面,但是如果您查看这一行,您可以看到它列出了该属性,同时指出它找不到它。
所以,它没有选择配置文件的位置,而是使用默认的位置。
这里有没有人用过jgroups和Hibernate Search?你有没有设法提供一个自定义的jgroups配置文件?你是怎么做到的?
发布于 2013-07-12 18:47:31
正确的。为了找到它,我不得不下载Hibernate搜索源并逐步启动服务器。我使用的是Hibernate 4.2
,我所指的文档版本主要是针对3.2
的。
在这两个版本之间,有人将该属性从hibernate.search.worker.backend.jgroups.configurationFile
重命名为hibernate.search.services.jgroups.configurationFile
。
https://stackoverflow.com/questions/17598574
复制相似问题