locking - @Lock(LockType.READ) Singleton Ejb in java 8 -


using java 7 jboss7 following code used work.

@singleton public class operacaoserviceimpl implements operacaoservice {      private operacao operacaoemandamento;      @override     @lock(locktype.read)     public operacao getoperacaoemandamento() {         return operacaoemandamento;     }      @override     @transactionattribute(transactionattributetype.not_supported)     public void geraeiniciaoperacao() throws coreexception {         geraoperacao();         iniciaoperacao();      } } 

now i've migrated java 8 wildfly stopped working. if geraeiniciaoperacao still running, can't access getoperacaoemandamento.

" javax.ejb.concurrentaccesstimeoutexception: wflyejb0241: ejb 3.1 pfd2 4.8.5.5.1 concurrent access timeout on operacaoserviceimpl - not obtain lock within 5000milliseconds @ org.jboss.as.ejb3.concurrency.containermanagedconcurrencyinterceptor.processinvocation(containermanagedconcurrencyinterceptor.java:106) ..."

i couldn't understand why used work. i've found is: container managed concurrency semantics "concurrent reads allowed long no writing going on". need "concurrent reads allowed, while writing goes on, 1 thread writing @ time". achieve i've changed class

@lock(locktype.read)

@singleton

public class operacaoserviceimpl implements operacaoservice {

and method

public void geraeiniciaoperacao() throws coreexception {

to

syncronized public void geraeiniciaoperacao() throws coreexception {

reference: ejb 3.1 container managed concurrency vs. synchronized


Comments