2012-02-19 40 views
0

有沒有人在春天成功地將infinispan設置爲L2 Cache?在Spring和Tomcat中使用Infinispan進行休眠L2 Cache

我想避免使用XA作爲我的數據源。目前我在JPATransactionManager中使用LocalContainerEntityManagerFactoryBean。

有關設置Infinispan所需的JTATransactionManager的任何提示?

我現在有以下的事務管理器: 請注意,您需要將entityManagerFactory傳遞給事務管理器。 因此,實體管理器需要完全創建以創建TransactionManager。 但是如果Infinispan需要TransactionManager,不會創建循環依賴嗎?

<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/> 
<!-- Transaction Manager --> 
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> 
    <property name="entityManagerFactory" ref="entityManagerFactory" /> 
    <property name="dataSource" ref="dataSource" /> 
</bean> 
<tx:advice id="txAdvice"/> 

更新:我使用bitronix,事情似乎是工作,但我會看到幾個警告:

1)在啓動時從Infinispan的:

STDOUT [WARN] [2012.02.20 14 :29:00] statetransfer.BaseStateTransferManagerImpl - ISPN000159:解鎖交易失敗 java.lang.IllegalStateException:試圖解鎖高速緩存視圖1的寫命令,但他們並沒有阻止 在org.infinispan.statetransfer.StateTransferLockImpl.unblockNewTransactions(StateTransferLockImpl.java :260) 在org.infinispan.statetransfer.BaseStateTransferManagerImpl.postInstallView(BaseStateTransferManagerImpl.java:351) 在org.infinispan.cacheviews.CacheViewsManagerImpl.handleCommitView(CacheViewsManagerImpl.java:520) 在org.infinispan.cacheviews.CacheViewsManagerImpl.clusterCommitView(CacheViewsManagerImpl。 Java的:387) 在org.infinispan.cacheviews.CacheViewsManagerImpl.clusterInstallView(CacheViewsManagerImpl.java:271) 在org.infinispan.cacheviews.CacheViewsManagerImpl $ ViewInstallationTask.call(CacheViewsManagerImpl.java:876) 在java.util.concurrent中。 FutureTask $ Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor $ Worker.runTask(ThreadPoolExecutor.java:886) 在java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:908) 在java.lang.Thread.run(Thread.java:680)

2)當運行一個寫事務:

STDOUT [WARN ] [2012.02.20 13:54:14] tm.BitronixTransaction - Synchronization.afterCompletion() call failed for org.hibernate.engine[email protected]67c61e31 
java.util.ConcurrentModificationException 
    at java.util.LinkedHashMap$LinkedHashIterator.nextEntry(LinkedHashMap.java:373) 
    at java.util.LinkedHashMap$KeyIterator.next(LinkedHashMap.java:384) 
    at org.hibernate.engine.transaction.internal.SynchronizationRegistryImpl.notifySynchronizationsAfterTransactionCompletion(SynchronizationRegistryImpl.java:78) 
    at org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl.sendAfterTransactionCompletionNotifications(TransactionCoordinatorImpl.java:333) 
    at org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl.afterTransaction(TransactionCoordinatorImpl.java:145) 
    at org.hibernate.engine.transaction.synchronization.internal.SynchronizationCallbackCoordinatorImpl.afterCompletion(SynchronizationCallbackCoordinatorImpl.java:126) 
    at org.hibernate.engine.transaction.synchronization.internal.RegisteredSynchronization.afterCompletion(RegisteredSynchronization.java:61) 
    at bitronix.tm.BitronixTransaction.fireAfterCompletionEvent(BitronixTransaction.java:497) 
    at bitronix.tm.BitronixTransaction.commit(BitronixTransaction.java:244) 
    at bitronix.tm.BitronixTransactionManager.commit(BitronixTransactionManager.java:120) 
    at org.springframework.transaction.jta.JtaTransactionManager.doCommit(JtaTransactionManager.java:1010) 
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754) 
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723) 
    at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:393) 
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:120) 
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
    at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:622) 
    at com.mckesson.dex.ui.administration.users.SiteUserResourceProvider$$EnhancerByCGLIB$$edc43389.save(<generated>) 
    at com.mckesson.dex.ui.viewer.AdaptableForm.save(AdaptableForm.java:407) 
    at com.mckesson.dex.ui.viewer.AdaptableForm.attemptSave(AdaptableForm.java:274) 
    at com.mckesson.dex.ui.viewer.AdaptableForm$5.buttonClick(AdaptableForm.java:323) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:512) 
    at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:164) 
    at com.vaadin.ui.AbstractComponent.fireEvent(AbstractComponent.java:1219) 
    at com.vaadin.ui.Button.fireClick(Button.java:550) 
    at com.vaadin.ui.Button.changeVariables(Button.java:217) 
    at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.changeVariables(AbstractCommunicationManager.java:1451) 
    at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariableBurst(AbstractCommunicationManager.java:1399) 
    at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariables(AbstractCommunicationManager.java:1318) 
    at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(AbstractCommunicationManager.java:763) 
    at com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(CommunicationManager.java:296) 
    at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:501) 
    at com.mckesson.dex.servlet.DexApplicationServlet.service(DexApplicationServlet.java:60) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) 
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:550) 
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1359) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:311) 
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:116) 
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323) 
    at com.mckesson.dex.security.filter.IpAddressAuditFilter.doFilterInternal(IpAddressAuditFilter.java:54) 
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323) 
    at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323) 
    at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:101) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323) 
    at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323) 
    at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323) 
    at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323) 
    at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323) 
    at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:182) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323) 
    at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323) 
    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323) 
    at org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:125) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323) 
    at com.mckesson.dex.security.DexConcurrentSessionFilter.doFilter(DexConcurrentSessionFilter.java:92) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323) 
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:173) 
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237) 
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167) 
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1330) 
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:484) 
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119) 
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:517) 
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:229) 
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:970) 
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:414) 
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:187) 
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:904) 
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117) 
    at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:149) 
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110) 
    at org.eclipse.jetty.server.Server.handle(Server.java:347) 
    at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:590) 
    at org.eclipse.jetty.server.HttpConnection$RequestHandler.content(HttpConnection.java:1071) 
    at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:823) 
    at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:220) 
    at org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:411) 
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:535) 
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:40) 
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:529) 
    at java.lang.Thread.run(Thread.java: 
+0

我找到了這個配置。我會看看我是否可以使用它來實現它。但是,我目前設置爲使用3個不同的數據庫(dev,tests,prod)=(postgres,h2,oracle)。 我在上下文配置中創建數據源並通過jndi註冊。所以我將不得不多花一點時間來看看使用這種配置的可行性。 https://github.com/hibernate/hibernate-search/blob/master/hibernate-search-integrationtest/src/test/resources/beans.xml – 2012-02-19 22:40:05

+0

這聽起來像是將Infinispan配置爲2LC的不錯來源,但您最有可能需要一個不同的hibernate.transaction.manager_lookup_class,一個指向JTA事務管理器。很奇怪你需要將一個實體管理器傳遞給一個事務管理器。事務管理器應該非常獨立,JPA應該以某種方式依賴它。 – 2012-02-20 10:46:46

+0

Re:狀態轉移中的IllegalStateException - 您使用的Infinispan版本是什麼? – 2012-02-21 11:05:46

回答