Hibernate Search..访问尚未密封的Sealed WorkQueue
我正在尝试将 Hibernate Search 用于新项目。我们有 Hibernate 和 Spring,但没有 JPA。当 Hibernate Search 尝试通过事件侦听器更新索引文件时,我收到以下异常。我已阅读过有关此问题的文章,但似乎没有任何内容对我有用。我真的很感激任何帮助。
环境: 春季3.0.5 休眠3.5.4 Hibernate Search 3.2.1
异常:
TransactionSy E org.springframework.transaction.support.TransactionSynchronizationUtils invokeAfterCompletion TransactionSynchronization.afterCompletion threw exception
org.hibernate.AssertionFailure: Exception releasing cache locks
at org.hibernate.engine.ActionQueue$AfterTransactionCompletionProcessQueue.afterTransactionCompletion(ActionQueue.java:584)
at org.hibernate.engine.ActionQueue.afterTransactionCompletion(ActionQueue.java:204)
at org.hibernate.impl.SessionImpl.afterTransactionCompletion(SessionImpl.java:594)
at org.springframework.orm.hibernate3.SpringSessionSynchronization.afterCompletion(SpringSessionSynchronization.java:229)
at org.springframework.transaction.support.TransactionSynchronizationUtils.invokeAfterCompletion(TransactionSynchronizationUtils.java:168)
at org.springframework.transaction.jta.JtaAfterCompletionSynchronization.afterCompletion(JtaAfterCompletionSynchronization.java:62)
at com.ibm.ws.uow.ComponentContextSynchronizationWrapper.afterCompletion(ComponentContextSynchronizationWrapper.java:83)
at com.ibm.tx.jta.RegisteredSyncs.coreDistributeAfter(RegisteredSyncs.java:357)
at com.ibm.ws.tx.jta.RegisteredSyncs.distributeAfter(RegisteredSyncs.java:317)
at com.ibm.tx.jta.TransactionImpl.distributeAfter(TransactionImpl.java:2933)
at com.ibm.tx.jta.TransactionImpl.postCompletion(TransactionImpl.java:2892)
at com.ibm.tx.jta.TransactionImpl.postCompletion(TransactionImpl.java:2805)
at com.ibm.tx.jta.TransactionImpl.commitXAResources(TransactionImpl.java:1775)
at com.ibm.ws.tx.jta.TransactionImpl.stage1CommitProcessing(TransactionImpl.java:497)
at com.ibm.tx.jta.TransactionImpl.processCommit(TransactionImpl.java:978)
at com.ibm.tx.jta.TransactionImpl.commit(TransactionImpl.java:913)
at com.ibm.ws.tx.jta.TranManagerImpl.commit(TranManagerImpl.java:369)
at com.ibm.tx.jta.TranManagerSet.commit(TranManagerSet.java:161)
at com.ibm.ws.uow.UOWManagerImpl.uowCommit(UOWManagerImpl.java:1172)
at com.ibm.ws.uow.UOWManagerImpl.uowEnd(UOWManagerImpl.java:1142)
at com.ibm.ws.uow.UOWManagerImpl.runUnderNewUOW(UOWManagerImpl.java:1092)
at com.ibm.ws.uow.UOWManagerImpl.runUnderUOW(UOWManagerImpl.java:626)
at org.springframework.transaction.jta.WebSphereUowTransactionManager.execute(WebSphereUowTransactionManager.java:281)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:127)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:621)
at com.test.service.inventory.InventoryServiceImpl$$EnhancerByCGLIB$$847cc0d8.updateInventoy(<generated>)
at com.test.web.servlet.SearchServlet.doPost(SearchServlet.java:51)
at com.test.web.servlet.SearchServlet.doGet(SearchServlet.java:75)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:718)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1449)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:790)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:443)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:175)
at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:91)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:859)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1557)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:173)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:455)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:384)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:272)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:202)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:766)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:896)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1527)
Caused by: org.hibernate.HibernateException: Error while indexing in Hibernate Search (ater transaction completion)
at org.hibernate.search.backend.impl.EventSourceTransactionContext$DelegateToSynchronizationOnAfterTx.doAfterTransactionCompletion(EventSourceTransactionContext.java:179)
at org.hibernate.engine.ActionQueue$AfterTransactionCompletionProcessQueue.afterTransactionCompletion(ActionQueue.java:577)
... 51 more
Caused by: org.hibernate.annotations.common.AssertionFailure: Access a Sealed WorkQueue which has not been sealed
at org.hibernate.search.backend.WorkQueue.getSealedQueue(WorkQueue.java:87)
at org.hibernate.search.backend.impl.BatchedQueueingProcessor.performWorks(BatchedQueueingProcessor.java:280)
at org.hibernate.search.backend.impl.PostTransactionWorkQueueSynchronization.afterCompletion(PostTransactionWorkQueueSynchronization.java:96)
at org.hibernate.search.backend.impl.EventSourceTransactionContext$DelegateToSynchronizationOnAfterTx.doAfterTransactionCompletion(EventSourceTransactionContext.java:176)
... 52 more
我知道有一个类似问题的修复程序 [#HSEARCH-540] 但这似乎对我不起作用。
这是我的 Spring 上下文:
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="com.test.entity.inventory" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.jdbc.batch_size">40</prop>
<!-- Hibernate Search properties -->
<prop key="hibernate.search.default.indexBase">/POC/index</prop>
<prop key="hibernate.search.default.directory_provider">org.hibernate.search.store.FSDirectoryProvider</prop>
</props>
</property>
</bean>
<bean id="transactionManager"
class="org.springframework.transaction.jta.WebSphereUowTransactionManager" />
<tx:annotation-driven />
<bean id="inventoryDao"
class="com.test.dao.inventory.InventoryDao">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
这是我的 inventoryDao 方法,它抛出异常。
@Transactional
public Inventory updateInventoy(long id) {
Inventory inv = null;
Session session = sessionFactory.getCurrentSession();
inv = (Inventory) session.load(Inventory.class, id);
inv.setPrice(100000);
inv.setModel("Testing123");
return inv;
}
数据库更新得很好,但我的索引没有更新。
请帮忙。提前致谢..
I am trying to use Hibernate Search for a new project. We have Hibernate and Spring without JPA. I m getting the following exception when Hibernate Search tries to update the index file thru the event listeners. I have read around on this issue but nothing seems to work for me. I would really appreciate any help.
Environment:
Spring 3.0.5
Hibernate 3.5.4
Hibernate Search 3.2.1
Exception:
TransactionSy E org.springframework.transaction.support.TransactionSynchronizationUtils invokeAfterCompletion TransactionSynchronization.afterCompletion threw exception
org.hibernate.AssertionFailure: Exception releasing cache locks
at org.hibernate.engine.ActionQueue$AfterTransactionCompletionProcessQueue.afterTransactionCompletion(ActionQueue.java:584)
at org.hibernate.engine.ActionQueue.afterTransactionCompletion(ActionQueue.java:204)
at org.hibernate.impl.SessionImpl.afterTransactionCompletion(SessionImpl.java:594)
at org.springframework.orm.hibernate3.SpringSessionSynchronization.afterCompletion(SpringSessionSynchronization.java:229)
at org.springframework.transaction.support.TransactionSynchronizationUtils.invokeAfterCompletion(TransactionSynchronizationUtils.java:168)
at org.springframework.transaction.jta.JtaAfterCompletionSynchronization.afterCompletion(JtaAfterCompletionSynchronization.java:62)
at com.ibm.ws.uow.ComponentContextSynchronizationWrapper.afterCompletion(ComponentContextSynchronizationWrapper.java:83)
at com.ibm.tx.jta.RegisteredSyncs.coreDistributeAfter(RegisteredSyncs.java:357)
at com.ibm.ws.tx.jta.RegisteredSyncs.distributeAfter(RegisteredSyncs.java:317)
at com.ibm.tx.jta.TransactionImpl.distributeAfter(TransactionImpl.java:2933)
at com.ibm.tx.jta.TransactionImpl.postCompletion(TransactionImpl.java:2892)
at com.ibm.tx.jta.TransactionImpl.postCompletion(TransactionImpl.java:2805)
at com.ibm.tx.jta.TransactionImpl.commitXAResources(TransactionImpl.java:1775)
at com.ibm.ws.tx.jta.TransactionImpl.stage1CommitProcessing(TransactionImpl.java:497)
at com.ibm.tx.jta.TransactionImpl.processCommit(TransactionImpl.java:978)
at com.ibm.tx.jta.TransactionImpl.commit(TransactionImpl.java:913)
at com.ibm.ws.tx.jta.TranManagerImpl.commit(TranManagerImpl.java:369)
at com.ibm.tx.jta.TranManagerSet.commit(TranManagerSet.java:161)
at com.ibm.ws.uow.UOWManagerImpl.uowCommit(UOWManagerImpl.java:1172)
at com.ibm.ws.uow.UOWManagerImpl.uowEnd(UOWManagerImpl.java:1142)
at com.ibm.ws.uow.UOWManagerImpl.runUnderNewUOW(UOWManagerImpl.java:1092)
at com.ibm.ws.uow.UOWManagerImpl.runUnderUOW(UOWManagerImpl.java:626)
at org.springframework.transaction.jta.WebSphereUowTransactionManager.execute(WebSphereUowTransactionManager.java:281)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:127)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:621)
at com.test.service.inventory.InventoryServiceImpl$EnhancerByCGLIB$847cc0d8.updateInventoy(<generated>)
at com.test.web.servlet.SearchServlet.doPost(SearchServlet.java:51)
at com.test.web.servlet.SearchServlet.doGet(SearchServlet.java:75)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:718)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1449)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:790)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:443)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:175)
at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:91)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:859)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1557)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:173)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:455)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:384)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:272)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:202)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:766)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:896)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1527)
Caused by: org.hibernate.HibernateException: Error while indexing in Hibernate Search (ater transaction completion)
at org.hibernate.search.backend.impl.EventSourceTransactionContext$DelegateToSynchronizationOnAfterTx.doAfterTransactionCompletion(EventSourceTransactionContext.java:179)
at org.hibernate.engine.ActionQueue$AfterTransactionCompletionProcessQueue.afterTransactionCompletion(ActionQueue.java:577)
... 51 more
Caused by: org.hibernate.annotations.common.AssertionFailure: Access a Sealed WorkQueue which has not been sealed
at org.hibernate.search.backend.WorkQueue.getSealedQueue(WorkQueue.java:87)
at org.hibernate.search.backend.impl.BatchedQueueingProcessor.performWorks(BatchedQueueingProcessor.java:280)
at org.hibernate.search.backend.impl.PostTransactionWorkQueueSynchronization.afterCompletion(PostTransactionWorkQueueSynchronization.java:96)
at org.hibernate.search.backend.impl.EventSourceTransactionContext$DelegateToSynchronizationOnAfterTx.doAfterTransactionCompletion(EventSourceTransactionContext.java:176)
... 52 more
I know there was a fix for a similar problem [#HSEARCH-540] but that does not seem to be working for me.
Here is my Spring context:
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="com.test.entity.inventory" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.jdbc.batch_size">40</prop>
<!-- Hibernate Search properties -->
<prop key="hibernate.search.default.indexBase">/POC/index</prop>
<prop key="hibernate.search.default.directory_provider">org.hibernate.search.store.FSDirectoryProvider</prop>
</props>
</property>
</bean>
<bean id="transactionManager"
class="org.springframework.transaction.jta.WebSphereUowTransactionManager" />
<tx:annotation-driven />
<bean id="inventoryDao"
class="com.test.dao.inventory.InventoryDao">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
Here is my inventoryDao method that is throwing the exception.
@Transactional
public Inventory updateInventoy(long id) {
Inventory inv = null;
Session session = sessionFactory.getCurrentSession();
inv = (Inventory) session.load(Inventory.class, id);
inv.setPrice(100000);
inv.setModel("Testing123");
return inv;
}
The database get updated fine however my index is not getting updated.
Please help. Thanks in advance..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了保持索引与数据库同步,您必须将 Hibernate 会话包装在全文会话中,如下所示:
然后使用全文会话代替包装会话。
To keep the index in sync with the database you have to wrap your Hibernate session in a full-text session, like so:
Then use the full-text session in place of the wrapped session.