Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1004 connectés 

  FORUM HardWare.fr
  Programmation
  Java

  synchronize LinkedHashMap ejb transaction.RollbackException

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

synchronize LinkedHashMap ejb transaction.RollbackException

n°2182730
jetaimerog​er
Posté le 27-03-2013 à 12:28:46  profilanswer
 

Hello i have often  
A system exception occurred during an invocation on EJB TotoCacheBean, method: public void ...TotoCacheBean.refreshAlertCache() ...: ATTENTION: javax.ejb.EJBException: Transaction aborted
Caused by: javax.transaction.RollbackException at com.sun.jts.jta.TransactionManagerImpl.commit(TransactionManagerImpl.java:334)
 
   

Citation :

@Singleton
    @PersistenceContext(name = "persistence/popul", unitName = "popul" )
    @TransactionAttribute(value = TransactionAttributeType.SUPPORTS)
    @ConcurrencyManagement(ConcurrencyManagementType.BEAN)
    @Startup
    public class TotoCacheBean
    {
     private final ReadWriteLock lock = new ReentrantReadWriteLock();
 
 @Inject
 private MessageDAO messageDAO;
 
 public enum Type
 {
  ALERT, GLOBAL
 };
 
 private Map<Type, TotoCache> cacheStorage;
 
 @PostConstruct
 public void postConstruct() throws DAOException
 {
  refreshAlertCache();
  refreshGlobalCache();
 }
 
 @Schedule(second = "*/20", minute = "*", hour = "*", persistent = false)
 public void refreshAlertCache() throws DAOException
 {
  refreshCache(Type.ALERT);
 }
 
 @Schedule(second = "10", minute = "*", hour = "*", persistent = false)
 public void refreshGlobalCache() throws DAOException
 {
  refreshCache(Type.GLOBAL);
 }  
 
 private void refreshCache(Type type) throws DAOException
 {
  Date now = DateTools.getDate();
  LinkedHashMap<String, LinkedHashMap<String, ActMessDTO>> messages = messageDAO.getActMessSorted(now, (type == Type.ALERT));
  setCache(type, new TotoCache(messages, now));
 }
 
 
 public TotoCache getCache(Type type)
 {
  lock.readLock().lock();
 
  try
  {
   return getCacheStorage().get(type);
  }
  finally
  {
   lock.readLock().unlock();
  }
 }
 
 private void setCache(Type type, TotoCache cache)
 {
  lock.writeLock().lock();
 
  try
  {
   getCacheStorage().put(type, cache);
  }
  finally
  {
   lock.writeLock().unlock();
  }
 }
 
 private Map<Type, TotoCache> getCacheStorage()
 {
  if (this.cacheStorage == null)
   this.cacheStorage = new HashMap<Type, TotoCache>();
 
  return this.cacheStorage;
 }
 
}


 
Have you some ideas to resolve the issue? The LinkedHashMap is not synchronized but i prefer not to change it because it will change more than 10 classes. but if it 's the reason i will do it.  
Or the probleme is the use of ReadWriteLock? thanks for your tricks
 

mood
Publicité
Posté le 27-03-2013 à 12:28:46  profilanswer
 

n°2182737
devicenotr​eady
insert disk and retry
Posté le 27-03-2013 à 13:41:45  profilanswer
 

Bonjour,
 
Ce serait sympa que tu traduises ton texte original en mauvais anglais avant de poster sur un forum francophone. (+balise "code" ). Merci.


---------------
http://devicenotready.com/ - Informatique et autres bizarreries

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  Java

  synchronize LinkedHashMap ejb transaction.RollbackException

 

Sujets relatifs
transaction lock ejb verrouJPA2.0 : entityManager.close() ferme t-il sa transaction?
[DB2] gestion de transactionJava, Hibernate, Spring, Transaction-Manager, DAO, ...
Caulcul Pourcentage transaction financièreTéléchargement JDK 6 (Your download transaction cannot be approved...)
Transaction sur plusieurs scripts phpDemande de conseil concernant les transaction serveur client
[SQL Server] MAJ de plusieurs bases dans une seule transactionTRansaction fonctionne en mode client/serveur ?
Plus de sujets relatifs à : synchronize LinkedHashMap ejb transaction.RollbackException


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR