1 Reply Latest reply on Feb 25, 2014 9:43 PM by mashama

    JCache @CacheRemoveEntry call causing transaction to rollback

    mashama

      I have a transactional method that calls an @CacheRemoveEntry annotated method on another bean.  I have set the transaction logging to TRACE to get some insight into an issue I am having.  Looking at the logs I can clearly see that when I comment out the call to the @CacheRemoveEntry annotated method the transaction is committed as expected however when the method is uncommented the transaction is rolled back and aborted.  I wanted to reach out to the WildFly community as I attempt to identify why exactly I am seeing this behavior. 

       

      class A {
      
        @Inject
        private B model;
      
        @Transactional
        public void doSomeWork(Long modelId) {
           …
           …
      
      
           model.clearCachedModel(modelId);
        }
      }
      

       

       

      @Model
      class B {
      
        @Inject
        private Logger log;
      
        @CacheRemoveEntry(cacheName="model-cache")
        public void clearCachedModel(Long modelId) {
             log.info("sweeet");
        }
      
      }
      

       

      I am seeing no exceptions being generated here nor do I see the INFO logging call.  Am I correct in assuming that the B.clearCachedModel(Long) call should not cause the transaction to rollback?  If so how can I get more insight into why the transaction is getting rolled back?  If not what am I not understanding here?

       

      m.

        • 1. Re: JCache @CacheRemoveEntry call causing transaction to rollback
          mashama

          So I did a little more digging today and I think I understand what is going on here.  I commented out the @Model annotation and my code started working as expected.  In my description above I neglected to document provide relevant implementation details.  This code is exercised in an asynchronous thread kicked off a call utilizing the new concurrent utilities API.  Thus there is no active request scope when B.clearCachedModel(Long) is called.

           

          Assuming that my understanding is now correct should I not expect some type of exception to be generated in this scenario?