我无法正确设置Hibernate Search的从属节点。我已经找到了关于这个主题的多篇文章并遵循它们,但它对我不起作用。我已经成功设置了主人。也许更多的眼睛可以看到我没有的东西。
我正在使用:
春天3.2
Hibernate Search 3.4.1
Hibernate 3.6.1
Apache Tomcat 7.0.27
ActiveMQ 5.9.0(独立。我也试过嵌入式,结果相同)。
应用程序META-INF \ context.xml:
<Context>
<Resource
name="jms/ConnectionFactory"
auth="Container"
type="org.apache.activemq.ActiveMQConnectionFactory"
description="JMS Connection Factory"
factory="org.apache.activemq.jndi.JNDIReferenceFactory"
brokerURL="tcp://localhost:61616"
brokerName="HibernateSearchBroker" />
<Resource
name="queue/hibernatesearch"
auth="Container" type="org.apache.activemq.command.ActiveMQQueue"
description="Hibernate search queue"
factory="org.apache.activemq.jndi.JNDIReferenceFactory"
physicalName="hibernateSearchQueue" />
</Context>
Hibernate dao-config.xml:
<bean id="breezeSessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="annotatedClasses">
<list>
...
</list>
</property>
<property name="hibernateProperties">
hibernate.search.worker.backend=jms
hibernate.search.worker.jndi.url=tcp://localhost:61616
hibernate.search.worker.jms.connection_factory=jms/ConnectionFactory (tried java:comp/env/jms/ConnectionFactory as well)
hibernate.search.worker.jms.queue=queue/hibernatesearch (tried java:comp/env/queue/hibernatesearch as well)
hibernate.search.worker.jndi.java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory
#hibernate.search.default.directory_provider=org.hibernate.search.store.FSSlaveDirectoryProvider (tried this as well)
hibernate.search.default.directory_provider = filesystem-slave
hibernate.search.default.refresh=120
hibernate.search.default.indexBase=[local]
hibernate.search.default.sourceBase=[share]
hibernate.search.retry_initialize_period=15
</property>
</bean>
堆栈追踪:
...
Caused by: org.hibernate.HibernateException: could not init listeners
at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:205)
at org.hibernate.cfg.Configuration.getInitializedEventListeners(Configuration.java:1980)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1842)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:863)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:782)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:188)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1545)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1483)
... 61 more
Caused by: org.hibernate.search.SearchException: Unable to lookup Search queue (queue/hibernatesearch ) and connection factory (jms/ConnectionFactory)
at org.hibernate.search.backend.impl.jms.JMSBackendQueueProcessorFactory.prepareJMSTools(JMSBackendQueueProcessorFactory.java:97)
at org.hibernate.search.backend.impl.jms.JMSBackendQueueProcessorFactory.initialize(JMSBackendQueueProcessorFactory.java:61)
at org.hibernate.search.backend.impl.BatchedQueueingProcessor.<init>(BatchedQueueingProcessor.java:108)
at org.hibernate.search.backend.impl.TransactionalWorker.initialize(TransactionalWorker.java:98)
at org.hibernate.search.backend.WorkerFactory.createWorker(WorkerFactory.java:69)
at org.hibernate.search.spi.SearchFactoryBuilder.buildNewSearchFactory(SearchFactoryBuilder.java:277)
at org.hibernate.search.spi.SearchFactoryBuilder.buildSearchFactory(SearchFactoryBuilder.java:144)
at org.hibernate.search.event.FullTextIndexEventListener.initialize(FullTextIndexEventListener.java:151)
at org.hibernate.event.EventListeners$1.processListener(EventListeners.java:198)
at org.hibernate.event.EventListeners.processListeners(EventListeners.java:181)
at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:194)
... 68 more
Caused by: javax.naming.NameNotFoundException: jms/ConnectionFactory
at org.apache.activemq.jndi.ReadOnlyContext.lookup(ReadOnlyContext.java:235)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
at org.hibernate.search.backend.impl.jms.JMSBackendQueueProcessorFactory.prepareJMSTools(JMSBackendQueueProcessorFactory.java:92)
... 78 more
对我来说,我没有正确配置JNDI名称 - 但是我已经尝试过每一个我能想到的组合。任何帮助表示赞赏。
答案 0 :(得分:0)
您可以在此博客中找到答案
http://aredko.blogspot.fr/2009/12/distributed-hibernate-search-with.html
<property name="hibernateProperties">
hibernate.search.worker.backend=jms
hibernate.search.worker.jndi.url=
hibernate.search.worker.jms.connection_factory=java:comp/env/jms/ConnectionFactory
hibernate.search.worker.jms.queue=java:comp/env/queue/hibernatesearch
hibernate.search.worker.jndi.java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory
hibernate.search.default.directory_provider=org.hibernate.search.store.FSSlaveDirectoryProvider
hibernate.search.default.refresh=120
hibernate.search.default.indexBase=[local]
hibernate.search.default.sourceBase=[share]
hibernate.search.retry_initialize_period=15
</property>
保留context.xml