I am making a proof of concept for a continuous web management process. To simulate, I create a counter to count the number of times every 1 second. I have a JSF page with a start / stop button. When I press start, I can check the log that the counter counts, but when I close the stop, I am faced with a timeout exception.
Here is the .xhtml graph
<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>
Here is 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());
}
}
Here is Counter.java
package nawa.bean;
import javax.ejb.*;
@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)
{
}
}
}
@Asynchronous
public void endCounting()
{
this.isRunning = false;
this.logger.addMessage("EndCounting(" + this.count + ")");
}
}
And here is the exception:
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]
Can anyone guide me? What's going on here? I am using JBoss 7.1.
thank
source
share