2 Replies Latest reply on Dec 30, 2010 8:33 PM by rizos.joker

    Problem with EHCache and JBoss 5.1.0

    rizos.joker

      I need help with this annoying problem. The exception I get is this:

       

      BMT stateless bean Bulk should complete transactions before returning (ejb1.1 spec, 11.6.1)
      

       

      Basically I'm getting some data from database and caching it.

       

      The error ocurrs when getting a singleton instace of an object which creates an instace of net.sf.ehcache.CacheManager. The singleton class looks something like this:

       

      .
      .
      .
      import net.sf.ehcache.Cache;
      import net.sf.ehcache.CacheException;
      import net.sf.ehcache.CacheManager;
      import net.sf.ehcache.Element;
      
      public class CacheBulkManager {
      
          [...]
          private CacheManager manager;
          private static CacheBulkManager instance;
      
          //Private constructor to implement singleton pattern
          private CacheBulkManager() {
              try {
                  manager = CacheManager.create();
              } catch (CacheException e) {
                  //...
              }
          }
      
          // static protected getInstance Method
          static CacheBulkManager getInstance() {
      
              if (CacheBulkManager.instance == null) {
                  CacheBulkManager.instance = new CacheBulkManager();
              }
              return CacheBulkManager.instance;
          }
      
          [...]
      
      }
      

       

      And then, witin a stateless session bean method I do something like this:

       

      ...
      private void storeObjects(...){
           try {
                  CacheBulkManager cacheBulkManager = CacheBulkManager.getInstance();
                [...]
           } catch (Exception e) {  
                [...]
           }finally{
                [...]
           } 
      }
      

       

      In that line where I get the singleton instace the method returns. This is, if I debug the .getInstace() method the application doesn't even get into it. The storeObjects() method just returns like if I placed a return; there.

       

      Actually, it doesn't catch any exception but falls into the finally block, so it is certainly returning before closing transaction like the exception says.

       

      So, my real problem isn't the exception itself but to know why this CacheBulkManager.getInstace() is making the method to return?. I think that maybe one of the net.sf.ehcache.* dependecies are doing something when JBoss load these classes which doesn't like to the server.

       

      By the way, this code worked fine in JBoss 4.2 for a long time, JBoss 5.1 is the one who doesn'y like it.

       

      Any ideas?