我们在 Weblogic 10 集群环境中使用 Spring Web Flow (2.0.9)。在生产中,我们得到了很多LockTimeoutException : Unable to acquire conversation lock after 30 seconds。
我一直在试图弄清楚为什么在某些情况下只有一次单击或我们正在访问网站本身的主页时会出现上述异常。
请在 SWF 中找到试图锁定 FlowController 的代码。我不知道是锁在正在访问的 servlet 上还是其他什么?
请帮助了解在 Web 应用程序中发生此锁定时哪个资源实际上被锁定在 SWF 中?
要了解 ReentrantLock 的概念,请参考下面的链接。
提前致谢。
异常堆栈跟踪
org.springframework.webflow.conversation.impl.LockTimeoutException: Unable to acquire conversation lock after 30 seconds
at org.springframework.webflow.conversation.impl.JdkConcurrentConversationLock.lock(JdkConcurrentConversationLock.java:44)
at org.springframework.webflow.conversation.impl.ContainedConversation.lock(ContainedConversation.java:69)
at org.springframework.webflow.execution.repository.support.ConversationBackedFlowExecutionLock.lock(ConversationBackedFlowExecutionLock.java:51)
at org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:166)
at org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:183)
at org.springframework.webflow.mvc.servlet.FlowController.handleRequest(FlowController.java:174)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
SWF 中的锁实现
package org.springframework.webflow.conversation.impl;
import java.io.Serializable;
import java.util.concurrent.locks.ReentrantLock;
/**
* A conversation lock that relies on a {@link ReentrantLock} within Java 5's <code>util.concurrent.locks</code>
* package.
*
* @author Keith Donald
*/
class JdkConcurrentConversationLock implements ConversationLock, Serializable {
/**
* The lock.
*/
private ReentrantLock lock = new ReentrantLock();
public void lock() {
// ensure non-reentrant behaviour
if (!lock.isHeldByCurrentThread()) {
lock.lock();
}
}
public void unlock() {
// ensure non-reentrant behaviour
if (lock.isHeldByCurrentThread()) {
lock.unlock();
}
}
}