Results 1 to 2 of 2
  1. #1
    jesaispas is offline Member
    Join Date
    Mar 2013
    Posts
    1
    Rep Power
    0

    Default EJBException: Transaction aborted, Cache, ReentrantReadWriteLock

    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(Tran sactionManagerImpl.java:334)

    @Singleton
    @PersistenceContext(name = "persistence/popul", unitName = "popul")
    @TransactionAttribute(value = TransactionAttributeType.SUPPORTS)
    @ConcurrencyManagement(ConcurrencyManagementType.B EAN)
    @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

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: EJBException: Transaction aborted, Cache, ReentrantReadWriteLock

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. The statement was aborted... error
    By Humphrey Bogart in forum New To Java
    Replies: 4
    Last Post: 10-14-2012, 03:00 AM
  2. Binary Cache
    By Collider in forum New To Java
    Replies: 10
    Last Post: 05-03-2012, 05:22 PM
  3. Replies: 4
    Last Post: 04-01-2011, 08:47 PM
  4. Configration or Cache (JCS)
    By yatin110 in forum New To Java
    Replies: 0
    Last Post: 06-24-2010, 12:06 PM
  5. Replies: 7
    Last Post: 06-08-2010, 02:36 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •