4

新しいプロジェクトに Hibernate Search を使用しようとしています。JPAなしでHibernateとSpringがあります。Hibernate Search がイベント リスナーを介してインデックス ファイルを更新しようとすると、次の例外が発生します。この問題について読み回しましたが、何もうまくいかないようです。助けていただければ幸いです。

環境: Spring 3.0.5 Hibernate 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]の修正があったことは知っていますが、それは私にとってはうまくいかないようです。

これが私の春のコンテキストです:

<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;
}

データベースは正常に更新されますが、インデックスは更新されません。

助けてください。前もって感謝します..

4

1 に答える 1

0

インデックスをデータベースと同期させるには、次のように Hibernate セッションをフルテキスト セッションでラップする必要があります。

FullTextSession session = Search.getFullTextSession(sessionFactory.getCurrentSession());

次に、ラップされたセッションの代わりにフルテキスト セッションを使用します。

于 2012-02-01T13:11:19.960 に答える