Web コントロールの長時間実行プロセスの概念実証を行っています。それをシミュレートするために、1 秒ごとに数をカウントするカウンターを作成します。開始/停止ボタンのある JSF ページがあります。開始を押すと、カウンターがカウントを開始したことをログで確認できますが、停止を閉じると、タイムアウト例外に直面しました。
ここにCount.xhtmlがあります
<f:view
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jstl/core">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Insert title here</title>
</head>
<body>
<h:form>
<h:commandButton value="Start" action="#{counter.start}" />
<h:commandButton value="End" action="#{counter.end}" />
</h:form>
</body>
</html>
</f:view>
ここに CounterFace.java があります
package nawa.bean;
import javax.ejb.EJB;
import javax.faces.bean.*;
@ManagedBean(name="counter")
@ApplicationScoped
public class CounterFace
{
@EJB
private Counter counter;
public void start()
{
counter.startCounting();
System.out.println(counter.toString());
}
public void stop()
{
counter.endCounting();
System.out.println(counter.toString());
}
}
ここに Counter.java があります
package nawa.bean;
import javax.ejb.*;
/**
* Session Bean implementation class Counter
*/
@Stateful
@LocalBean
public class Counter
{
private int count = 0;
volatile boolean isRunning = false;
@EJB
private Logger logger;
private void count()
{
this.count++;
this.logger.addMessage("Counter(" + this.count + ")");
}
public boolean isRunning()
{
return this.isRunning;
}
@Asynchronous
public void startCounting()
{
this.isRunning = true;
while (this.isRunning)
{
this.count();
try
{
Thread.sleep(1000);
}
catch (InterruptedException e)
{
// TODO: handle exception
}
}
}
@Asynchronous
public void endCounting()
{
this.isRunning = false;
this.logger.addMessage("EndCounting(" + this.count + ")");
}
}
そして、ここに例外があります:
18:15:55,418 ERROR [org.jboss.as.ejb3] (EJB default - 3) JBAS014102: Asynchronous invocation failed: javax.ejb.ConcurrentAccessTimeoutException: JBAS014360: EJB 3.1 FR 4.3.14.1 concurrent access timeout on org.jboss.invocation.InterceptorContext@3a552b48 - could not obtain lock within 5000 MILLISECONDS
at org.jboss.as.ejb3.component.stateful.StatefulSessionSynchronizationInterceptor.processInvocation(StatefulSessionSynchronizationInterceptor.java:117) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at org.jboss.as.ejb3.component.stateful.StatefulComponentInstanceInterceptor.processInvocation(StatefulComponentInstanceInterceptor.java:66) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:228) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:304) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:190) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
誰でも私を案内できますか?ここで何が起こっているのですか?JBoss 7.1 を使用しています。
ありがとう